-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.0] Rework driver exceptions #3367
Conversation
…having to replicate the \PDOStatement interface in ResultStatement
3850154
to
4fbe91a
Compare
a640b82
to
e7b6c16
Compare
10890d6
to
3836750
Compare
@BenMorel I made some progress recently cleaning up driver exceptions in #4072, #4085, #4125, #4130, and other PRs (see the history of the Currently, some of the problems you were trying to solve are solved but not everything is changed the way you planned to. Do you want to try and rebase your PR onto |
@morozov I’m on vacation right now, I’ll try to look into this as soon as I get back! |
Looking at I'm therefore closing this PR, and would rather open a new one if I were to suggest other changes in the future. Thank you. |
Sounds good. Thanks for following up, @BenMorel. |
Summary
Consumers of the
Driver\Connection
API are not interested in catching individual exceptions implementingDriver\DriverException
, and will alwayscatch (DriverException)
.As such, the multiple implementations of DriverException provide little to no value, clutter the codebase, and force introducing a new exception class or using
new class
whenever we need to throw a DriverException from a new place.This design was probably chosen for 2 reasons:
Driver\PDOConnection
originally extended\PDO
, and as suchDriver\PDOException
extended\PDOException
. To implement an interface common to all drivers, it was chosen to create aninterface DriverException
, thatDriver\PDOException
would implement, while still extending\PDOException
. This requirement is gone, as the DBAL is evolving away from extending PDO, towards encapsulation.Proposed changes
AbstractDriverException
is now a concreteDriverException
, replacing the interfacenew class ... extends AbstractDriverException
are now replaced withnew DriverException
public static
method in the Connection, that can be used from within the Connection itself and from the StatementDriverException
This last point is very important: so far, most of the methods had no documented exceptions, while
query()
andexec()
were documented as throwingDBALException
, a contract that was never respected:PDOConnection::query()
andexec()
throwDriver\PDOException
, which is aDriverException
, not aDBALException
DB2Exception::query()
andexec()
throwDB2Exception
, which is aDriverException
SQLSrvException::query()
andexec()
throwSQLSrvException
(viaSQLSrvStatement::execute()
), which is aDriverException