Adding handling of PDOException

commit is auto-explanatory.