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()
121 """Translate a C++ Exception instance to Python and return it.""" 122 PyType = registry.get(type(cpp),
None)
124 warnings.warn(
"Could not find appropriate Python type for C++ Exception")
129 def declare(module, exception_name, base, wrapped_class):
130 """Declare a new exception.""" 132 dict(WrappedClass=wrapped_class))))
def __getattr__(self, name)
def __init__(self, arg, args, kwds)
def declare(module, exception_name, base, wrapped_class)