summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/exc.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-07-16 17:29:02 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-07-16 17:29:02 -0400
commitce9a702dbd52946487f45b98ef20d1b7783facb6 (patch)
tree7273a1982850bf9975509295d766053d4fe822b1 /lib/sqlalchemy/exc.py
parent1dc09bf6ede97ef08b2c8c0886a03b44bba735ff (diff)
downloadsqlalchemy-ce9a702dbd52946487f45b98ef20d1b7783facb6.tar.gz
- express most of the orm.util functions in terms of the inspection system
- modify inspection system: 1. raise a new exception for any case where the inspection context can't be returned. this supersedes the "not mapped" errors. 2. don't configure mappers on a mapper inspection. this allows the inspectors to be used during mapper config time. instead, the mapper configures on "with_polymorphic_selectable" now, which is needed for all queries - add a bunch of new "is_XYZ" attributes to inspectors - finish making the name change of "compile" -> "configure", for some reason this was only done partially
Diffstat (limited to 'lib/sqlalchemy/exc.py')
-rw-r--r--lib/sqlalchemy/exc.py56
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py
index f28bd8a07..0d69795d1 100644
--- a/lib/sqlalchemy/exc.py
+++ b/lib/sqlalchemy/exc.py
@@ -35,21 +35,21 @@ class AmbiguousForeignKeysError(ArgumentError):
class CircularDependencyError(SQLAlchemyError):
"""Raised by topological sorts when a circular dependency is detected.
-
+
There are two scenarios where this error occurs:
-
+
* In a Session flush operation, if two objects are mutually dependent
- on each other, they can not be inserted or deleted via INSERT or
+ on each other, they can not be inserted or deleted via INSERT or
DELETE statements alone; an UPDATE will be needed to post-associate
or pre-deassociate one of the foreign key constrained values.
- The ``post_update`` flag described at :ref:`post_update` can resolve
+ The ``post_update`` flag described at :ref:`post_update` can resolve
this cycle.
* In a :meth:`.MetaData.create_all`, :meth:`.MetaData.drop_all`,
:attr:`.MetaData.sorted_tables` operation, two :class:`.ForeignKey`
or :class:`.ForeignKeyConstraint` objects mutually refer to each
other. Apply the ``use_alter=True`` flag to one or both,
see :ref:`use_alter`.
-
+
"""
def __init__(self, message, cycles, edges, msg=None):
if msg is None:
@@ -61,7 +61,7 @@ class CircularDependencyError(SQLAlchemyError):
self.edges = edges
def __reduce__(self):
- return self.__class__, (None, self.cycles,
+ return self.__class__, (None, self.cycles,
self.edges, self.args[0])
class CompileError(SQLAlchemyError):
@@ -70,23 +70,19 @@ class CompileError(SQLAlchemyError):
class IdentifierError(SQLAlchemyError):
"""Raised when a schema name is beyond the max character limit"""
-# Moved to orm.exc; compatibility definition installed by orm import until 0.6
-ConcurrentModificationError = None
class DisconnectionError(SQLAlchemyError):
"""A disconnect is detected on a raw DB-API connection.
This error is raised and consumed internally by a connection pool. It can
- be raised by the :meth:`.PoolEvents.checkout` event
+ be raised by the :meth:`.PoolEvents.checkout` event
so that the host pool forces a retry; the exception will be caught
- three times in a row before the pool gives up and raises
+ three times in a row before the pool gives up and raises
:class:`~sqlalchemy.exc.InvalidRequestError` regarding the connection attempt.
"""
-# Moved to orm.exc; compatibility definition installed by orm import until 0.6
-FlushError = None
class TimeoutError(SQLAlchemyError):
"""Raised when a connection pool times out on getting a connection."""
@@ -99,6 +95,10 @@ class InvalidRequestError(SQLAlchemyError):
"""
+class NoInspectionAvailable(InvalidRequestError):
+ """A class to :func:`sqlalchemy.inspection.inspect` produced
+ no context for inspection."""
+
class ResourceClosedError(InvalidRequestError):
"""An operation was requested from a connection, cursor, or other
object that's in a closed state."""
@@ -128,7 +128,7 @@ class NoReferencedColumnError(NoReferenceError):
self.column_name = cname
def __reduce__(self):
- return self.__class__, (self.args[0], self.table_name,
+ return self.__class__, (self.args[0], self.table_name,
self.column_name)
class NoSuchTableError(InvalidRequestError):
@@ -143,20 +143,20 @@ 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
emitted within the process of executing a statement.
-
+
E.g.::
from sqlalchemy.exc import DontWrapMixin
-
+
class MyCustomException(Exception, DontWrapMixin):
pass
-
+
class MySpecialType(TypeDecorator):
impl = String
-
+
def process_bind_param(self, value, dialect):
if value == 'invalid':
raise MyCustomException("invalid!")
-
+
"""
import sys
if sys.version_info < (2, 5):
@@ -168,15 +168,15 @@ UnmappedColumnError = None
class StatementError(SQLAlchemyError):
"""An error occurred during execution of a SQL statement.
-
+
:class:`StatementError` wraps the exception raised
during execution, and features :attr:`.statement`
and :attr:`.params` attributes which supply context regarding
the specifics of the statement which had an issue.
- The wrapped exception object is available in
+ The wrapped exception object is available in
the :attr:`.orig` attribute.
-
+
"""
statement = None
@@ -195,7 +195,7 @@ class StatementError(SQLAlchemyError):
self.orig = orig
def __reduce__(self):
- return self.__class__, (self.args[0], self.statement,
+ return self.__class__, (self.args[0], self.statement,
self.params, self.orig)
def __str__(self):
@@ -218,7 +218,7 @@ class DBAPIError(StatementError):
:class:`DBAPIError` features :attr:`~.StatementError.statement`
and :attr:`~.StatementError.params` attributes which supply context regarding
- the specifics of the statement which had an issue, for the
+ the specifics of the statement which had an issue, for the
typical case when the error was raised within the context of
emitting a SQL statement.
@@ -228,8 +228,8 @@ class DBAPIError(StatementError):
"""
@classmethod
- def instance(cls, statement, params,
- orig,
+ def instance(cls, statement, params,
+ orig,
dbapi_base_err,
connection_invalidated=False):
# Don't ever wrap these, just return them directly as if
@@ -243,7 +243,7 @@ class DBAPIError(StatementError):
if not isinstance(orig, dbapi_base_err) and statement:
return StatementError(
"%s (original cause: %s)" % (
- str(orig),
+ str(orig),
traceback.format_exception_only(orig.__class__, orig)[-1].strip()
), statement, params, orig)
@@ -254,7 +254,7 @@ class DBAPIError(StatementError):
return cls(statement, params, orig, connection_invalidated)
def __reduce__(self):
- return self.__class__, (self.statement, self.params,
+ return self.__class__, (self.statement, self.params,
self.orig, self.connection_invalidated)
def __init__(self, statement, params, orig, connection_invalidated=False):
@@ -265,7 +265,7 @@ class DBAPIError(StatementError):
except Exception, e:
text = 'Error in str() of DB-API-generated exception: ' + str(e)
StatementError.__init__(
- self,
+ self,
'(%s) %s' % (orig.__class__.__name__, text),
statement,
params,