diff options
Diffstat (limited to 'lib/sqlalchemy/ext/compiler.py')
-rw-r--r-- | lib/sqlalchemy/ext/compiler.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index c27907cdc..b8b6f8dc0 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -398,6 +398,7 @@ Example usage:: """ from .. import exc +from .. import util from ..sql import sqltypes from ..sql import visitors @@ -422,10 +423,13 @@ def compiles(class_, *specs): def _wrap_existing_dispatch(element, compiler, **kw): try: return existing_dispatch(element, compiler, **kw) - except exc.UnsupportedCompilationError: - raise exc.CompileError( - "%s construct has no default " - "compilation handler." % type(element) + except exc.UnsupportedCompilationError as uce: + util.raise_( + exc.CompileError( + "%s construct has no default " + "compilation handler." % type(element) + ), + from_=uce, ) existing.specs["default"] = _wrap_existing_dispatch @@ -470,10 +474,13 @@ class _dispatcher(object): if not fn: try: fn = self.specs["default"] - except KeyError: - raise exc.CompileError( - "%s construct has no default " - "compilation handler." % type(element) + except KeyError as ke: + util.raise_( + exc.CompileError( + "%s construct has no default " + "compilation handler." % type(element) + ), + replace_context=ke, ) # if compilation includes add_to_result_map, collect add_to_result_map |