More meaningful exception on DB errors
In case of a wrong Database Connection specification (wrong host, wrong socket, credentials, database not existing, ...) the user should get meaningful exception messages.
Bug auction task won by T3N.
Updated by Karsten Dambekalns over 10 years ago
- Status changed from Accepted to Needs Feedback
Ok, catching DB errors is rather hard. Obvious things that break setting up the connection completely (e.g. wrong PDO driver specified) can be caught when creating the EntityManager. Other errors only occur when the database is used (connection established, select issued, ...). Thus handling this consistently is hard and would ideally be done by Doctrine's DBAL directly in a meaningful way, so we can react.
Question: what is so bad about the generated exceptions? I would love to see a handful of "most wanted" examples here, as for me the following is as clear as it gets:
Uncaught Exception in FLOW3 The given 'driver' pdo_joomla is unknown, Doctrine currently supports only the following drivers: … Uncaught Exception in FLOW3 #1049: SQLSTATE  Unknown database 'drupal' Uncaught Exception in FLOW3 #1045: SQLSTATE  Access denied for user 'fabien'@'localhost' (using password: YES)
I could imagine some really nice handling of errors based on SQL-92 sqlstate codes, but those are not (correctly) mapped for all cases in either drivers or database implementations.
The next best thing would be the errorInfo() at least for PDO connections, but given the above mentioned state of standardized sqlstate codes that's about the same as the native driver error message (or worse).