Feature #26411

More meaningful exception on DB errors

Added by Karsten Dambekalns over 10 years ago. Updated over 10 years ago.

Must have
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Has patch:


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

  • Tracker changed from Bug to Feature

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[42000] [1049] Unknown database 'drupal'
Uncaught Exception in FLOW3 #1045: SQLSTATE[28000] [1045] 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).


Updated by Karsten Dambekalns over 10 years ago

  • Status changed from Needs Feedback to Closed

Closing this one, as there's not much that can be done.

Also available in: Atom PDF