summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/exc.py
diff options
context:
space:
mode:
authorScott Dugas <scott.dugas@foundationdb.com>2014-11-03 14:54:51 -0500
committerScott Dugas <scott.dugas@foundationdb.com>2014-11-03 14:54:51 -0500
commitb31ab006897d2709442f9745faf0cac6e0de1713 (patch)
treea6b428e9ca7f1f67c5193581ecd82a83632eeb79 /lib/sqlalchemy/exc.py
parentebb9d57cb385f49becbf54c6f78647715ddd1c29 (diff)
parent7bf5ac9c1e814c999d4930941935e1d5cfd236bf (diff)
downloadsqlalchemy-b31ab006897d2709442f9745faf0cac6e0de1713.tar.gz
Merge branch 'master' into fdbsql-tests
Conflicts: lib/sqlalchemy/testing/exclusions.py
Diffstat (limited to 'lib/sqlalchemy/exc.py')
-rw-r--r--lib/sqlalchemy/exc.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py
index a82bae33f..3271d09d4 100644
--- a/lib/sqlalchemy/exc.py
+++ b/lib/sqlalchemy/exc.py
@@ -238,14 +238,16 @@ class StatementError(SQLAlchemyError):
def __str__(self):
from sqlalchemy.sql import util
- params_repr = util._repr_params(self.params, 10)
+ details = [SQLAlchemyError.__str__(self)]
+ if self.statement:
+ details.append("[SQL: %r]" % self.statement)
+ if self.params:
+ params_repr = util._repr_params(self.params, 10)
+ details.append("[parameters: %r]" % params_repr)
return ' '.join([
"(%s)" % det for det in self.detail
- ] + [
- SQLAlchemyError.__str__(self),
- repr(self.statement), repr(params_repr)
- ])
+ ] + details)
def __unicode__(self):
return self.__str__()
@@ -280,17 +282,19 @@ class DBAPIError(StatementError):
connection_invalidated=False):
# Don't ever wrap these, just return them directly as if
# DBAPIError didn't exist.
- if isinstance(orig, (KeyboardInterrupt, SystemExit, DontWrapMixin)):
+ if (isinstance(orig, BaseException) and
+ not isinstance(orig, Exception)) or \
+ isinstance(orig, DontWrapMixin):
return orig
if orig is not None:
# not a DBAPI error, statement is present.
# raise a StatementError
if not isinstance(orig, dbapi_base_err) and statement:
- msg = traceback.format_exception_only(
- orig.__class__, orig)[-1].strip()
return StatementError(
- "%s (original cause: %s)" % (str(orig), msg),
+ "(%s.%s) %s" %
+ (orig.__class__.__module__, orig.__class__.__name__,
+ orig),
statement, params, orig
)
@@ -310,13 +314,12 @@ class DBAPIError(StatementError):
def __init__(self, statement, params, orig, connection_invalidated=False):
try:
text = str(orig)
- except (KeyboardInterrupt, SystemExit):
- raise
except Exception as e:
text = 'Error in str() of DB-API-generated exception: ' + str(e)
StatementError.__init__(
self,
- '(%s) %s' % (orig.__class__.__name__, text),
+ '(%s.%s) %s' % (
+ orig.__class__.__module__, orig.__class__.__name__, text, ),
statement,
params,
orig