Merge lp:~cjwatson/storm/refactor-exception-wrapping into lp:storm
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 509 | ||||||||
Proposed branch: | lp:~cjwatson/storm/refactor-exception-wrapping | ||||||||
Merge into: | lp:storm | ||||||||
Diff against target: |
423 lines (+228/-31) 6 files modified
NEWS (+4/-0) storm/database.py (+132/-1) storm/databases/postgres.py (+28/-7) storm/databases/sqlite.py (+15/-9) storm/exceptions.py (+46/-14) tests/database.py (+3/-0) |
||||||||
To merge this branch: | bzr merge lp:~cjwatson/storm/refactor-exception-wrapping | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Simon Poirier (community) | Approve | ||
Review via email: mp+369319@code.launchpad.net |
Commit message
Wrap DB-API exceptions rather than injecting virtual base classes.
Description of the change
Re-raise DB-API exceptions wrapped in exception types that inherit from both StormError and the appropriate DB-API exception type, rather than injecting virtual base classes. This preserves existing exception handling in applications while also being a viable approach in Python 3.
Once I managed to get the right wrappers in place, this ended up being surprisingly simple, which makes me feel good about it (my first draft had many more explicit calls to wrap_exceptions and so felt much more fragile). The main difficulty was in creating just the right wrapper exception types to maintain API compatibility without making the code painfully repetitive, and I finally got that to fall into place today.
I'm running the full Launchpad test suite over this at the moment, though it looks clean so far and I've already found and fixed some problems via some of its most Storm-sensitive tests.
I've done a full successful Launchpad test run with this patch. The only change I had to make to Launchpad was to adjust LaunchpadDataba se.__init_ _, which is just because it's subclassing Postgres while (for unrelated reasons) not running the superclass constructor, so as a consequence it has to keep up with changes to the superclass constructor, which I think is fine.