From 08a6a8b51916ab1d084a0070bbb07001cabb1c38 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 22 Sep 2013 20:35:40 -0400 Subject: - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynor --- lib/sqlalchemy/exc.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/sqlalchemy/exc.py') diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index cfd1e2bc7..7ebdc3983 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -187,10 +187,6 @@ class DontWrapMixin(object): raise MyCustomException("invalid!") """ -import sys -if sys.version_info < (2, 5): - class DontWrapMixin: - pass # Moved to orm.exc; compatibility definition installed by orm import until 0.6 UnmappedColumnError = None -- cgit v1.2.1 From fc64812bad75fc5ecbfc95d715ed526994dc61ec Mon Sep 17 00:00:00 2001 From: Vraj Mohan Date: Thu, 14 Nov 2013 10:42:35 -0500 Subject: Fix references to exceptions --- lib/sqlalchemy/exc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/exc.py') diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 7ebdc3983..3c0c6c365 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -6,9 +6,9 @@ """Exceptions used with SQLAlchemy. -The base exception class is :class:`.SQLAlchemyError`. Exceptions which are +The base exception class is :exc:`.SQLAlchemyError`. Exceptions which are raised as a result of DBAPI exceptions are all subclasses of -:class:`.DBAPIError`. +:exc:`.DBAPIError`. """ @@ -169,7 +169,7 @@ class UnboundExecutionError(InvalidRequestError): class DontWrapMixin(object): """A mixin class which, when applied to a user-defined Exception class, - will not be wrapped inside of :class:`.StatementError` if the error is + will not be wrapped inside of :exc:`.StatementError` if the error is emitted within the process of executing a statement. E.g.:: -- cgit v1.2.1 From 9087157749a0527d6af37e58166793fc7e2f0bf7 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 11 Dec 2013 14:30:18 -0500 Subject: - The :class:`.exc.StatementError` or DBAPI-related subclass now can accomodate additional information about the "reason" for the exception; the :class:`.Session` now adds some detail to it when the exception occurs within an autoflush. This approach is taken as opposed to combining :class:`.FlushError` with a Python 3 style "chained exception" approach so as to maintain compatibility both with Py2K code as well as code that already catches ``IntegrityError`` or similar. --- lib/sqlalchemy/exc.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/exc.py') diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 3c0c6c365..93722fe99 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -219,6 +219,10 @@ class StatementError(SQLAlchemyError): self.statement = statement self.params = params self.orig = orig + self.detail = [] + + def add_detail(self, msg): + self.detail.append(msg) def __reduce__(self): return self.__class__, (self.args[0], self.statement, @@ -227,8 +231,13 @@ class StatementError(SQLAlchemyError): def __str__(self): from sqlalchemy.sql import util params_repr = util._repr_params(self.params, 10) - return ' '.join((SQLAlchemyError.__str__(self), - repr(self.statement), repr(params_repr))) + + return ' '.join([ + "(%s)" % det for det in self.detail + ] + [ + SQLAlchemyError.__str__(self), + repr(self.statement), repr(params_repr) + ]) def __unicode__(self): return self.__str__() -- cgit v1.2.1 From f89d4d216bd7605c920b7b8a10ecde6bfea2238c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 5 Jan 2014 16:57:05 -0500 Subject: - happy new year --- lib/sqlalchemy/exc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqlalchemy/exc.py') diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 93722fe99..fe6879b16 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -1,5 +1,5 @@ # sqlalchemy/exc.py -# Copyright (C) 2005-2013 the SQLAlchemy authors and contributors +# Copyright (C) 2005-2014 the SQLAlchemy authors and contributors # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -- cgit v1.2.1 From 1af8e2491dcbed723d2cdafd44fd37f1a6908e91 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 18 Jan 2014 19:26:56 -0500 Subject: - implement kwarg validation and type system for dialect-specific arguments; [ticket:2866] - add dialect specific kwarg functionality to ForeignKeyConstraint, ForeignKey --- lib/sqlalchemy/exc.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/sqlalchemy/exc.py') diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index fe6879b16..68e517e26 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -26,6 +26,9 @@ class ArgumentError(SQLAlchemyError): """ +class NoSuchModuleError(ArgumentError): + """Raised when a dynamically-loaded module (usually a database dialect) + of a particular name cannot be located.""" class NoForeignKeysError(ArgumentError): """Raised when no foreign keys can be located between two selectables -- cgit v1.2.1