Handling errors with PDO exceptions