1 from __future__
import absolute_import
2 from future
import standard_library
3 standard_library.install_aliases()
7 from future.utils
import with_metaclass
8 from .
import exceptions
14 """A Python decorator that adds a Python exception wrapper to the registry that maps C++ Exceptions 15 to their Python wrapper classes. 17 registry[cls.WrappedClass] = cls
22 """A metaclass for custom exception wrappers, which adds lookup of class attributes 23 by delegating to the Swig-generated wrapper. 27 return getattr(self.WrappedClass, name)
32 """The base class for Python-wrapped LSST C++ exceptions. 37 __module__ =
"lsst.pex.exceptions" 48 super(Exception, self).
__init__(message)
52 return getattr(self.
cpp, name)
55 return "%s('%s')" % (type(self).__name__, self.
cpp.what())
58 return self.
cpp.asString()
132 """Translate a C++ Exception instance to Python and return it.""" 133 PyType = registry.get(type(cpp),
None)
135 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.""" 141 setattr(module, exception_name,
register(
ExceptionMeta(exception_name, (base, ), dict(WrappedClass=wrapped_class))))
def __getattr__(self, name)
def __init__(self, arg, args, kwds)
def declare(module, exception_name, base, wrapped_class)