diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-10-22 19:24:02 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-10-22 19:24:02 +0000 |
commit | 9d7c027cb76d467d2f044952287f92bb61016617 (patch) | |
tree | cd8afd1c7d9fee795e291a896f6a79b4a9633774 /lib/sqlalchemy/exceptions.py | |
parent | 20a7a172af16a679ee141008be5a3da1fcab4b90 (diff) | |
download | sqlalchemy-9d7c027cb76d467d2f044952287f92bb61016617.tar.gz |
- Now guarding against broken DB-APIs when wrapping their exceptions.
- Added an explicit test for exception wrapping.
Diffstat (limited to 'lib/sqlalchemy/exceptions.py')
-rw-r--r-- | lib/sqlalchemy/exceptions.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/exceptions.py b/lib/sqlalchemy/exceptions.py index 9c7caedd0..decde0efa 100644 --- a/lib/sqlalchemy/exceptions.py +++ b/lib/sqlalchemy/exceptions.py @@ -96,8 +96,14 @@ class DBAPIError(SQLAlchemyError): instance = classmethod(instance) def __init__(self, statement, params, orig): - SQLAlchemyError.__init__(self, "(%s) %s" % - (orig.__class__.__name__, str(orig))) + try: + text = str(orig) + except (KeyboardInterrupt, SystemExit): + raise + except Exception, e: + text = 'Error in str() of DB-API-generated exception: ' + str(e) + SQLAlchemyError.__init__( + self, "(%s) %s" % (orig.__class__.__name__, text)) self.statement = statement self.params = params self.orig = orig |