1 from __future__
import absolute_import
5 from future.utils
import with_metaclass
6 from .
import exceptions
13 """A Python decorator that adds a Python exception wrapper to the registry that maps C++ Exceptions
14 to their Python wrapper classes.
16 registry[cls.WrappedClass] = cls
21 """A metaclass for custom exception wrappers, which adds lookup of class attributes
22 by delegating to the Swig-generated wrapper.
26 return getattr(self.WrappedClass, name)
31 """The base class for Python-wrapped LSST C++ exceptions.
36 __module__ =
"lsst.pex.exceptions"
47 super(Exception, self).
__init__(message)
51 return getattr(self.
cpp, name)
54 return "%s('%s')" % (type(self).__name__, self.cpp.what())
57 return self.cpp.asString()
131 """Translate a C++ Exception instance to Python and return it."""
132 PyType = registry.get(type(cpp),
None)
134 warnings.warn(
"Could not find appropriate Python type for C++ Exception")
139 def declare(module, exception_name, base, wrapped_class):
140 """Declare a new exception."""
142 dict(WrappedClass=wrapped_class))))