Feature #26411

More meaningful exception on DB errors

Added by Karsten Dambekalns over 4 years ago. Updated about 4 years ago.

Status:Closed Start date:2011-04-28
Priority:Must have Due date:
Assigned To:Karsten Dambekalns % Done:

0%

Category:Persistence
Target version:TYPO3 Flow Base Distribution - 1.0 beta 1
PHP Version: Complexity:
Has patch:

Description

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.

History

#1 Updated by Karsten Dambekalns over 4 years ago

  • Tracker changed from Bug to Feature

#2 Updated by Karsten Dambekalns over 4 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).

#3 Updated by Karsten Dambekalns about 4 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