Raise DBAPI-style exceptions instead of SQLError where possible
Issue #706
resolved
Sorry if this is an old idea, but I couldn't find it in my searches...
Instead of converting DBAPI exceptions to generic SQLError, mirror each DBAPI DatabaseError subclass with an identically-named subclass of SQLError. Then the programmer can catch the exception he wants directly instead of having to catch all SQLErrors, check orig, and re-raise if it's not the right one.
Comments (3)
-
repo owner -
- changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
nice idea. The error classes would still be "wrapping" the original one, so we're just talking about the catches here. im not sure if the various DBAPIs are really consistent with when they throw OperationalError vs. IntegrityError etc.
Id propose we change the hierarchy to be like this:
DBAPIError can use a metaclass or new to automatically produce the subclass corresponding to the given dbapi error.
Also existing uses for DBAPIError which aren't wrapping a real dbapi error, theres like two or three, should go to ArgumentErrors or InvalidRequestErrors.