1 from __future__
import absolute_import
3 __all__ = [
"register",
"ExceptionMeta",
"Exception",
"LogicError",
4 "DomainError",
"InvalidParameterError",
"LengthError",
5 "OutOfRangeError",
"RuntimeError",
"RangeError",
"OverflowError",
6 "UnderflowError",
"NotFoundError",
"IoError",
"TypeError",
7 "translate",
"declare"]
12 from future.utils
import with_metaclass
13 from .
import exceptions
19 """A Python decorator that adds a Python exception wrapper to the registry that maps C++ Exceptions 20 to their Python wrapper classes. 22 registry[cls.WrappedClass] = cls
27 """A metaclass for custom exception wrappers, which adds lookup of class attributes 28 by delegating to the Swig-generated wrapper. 32 return getattr(self.WrappedClass, name)
37 """The base class for Python-wrapped LSST C++ exceptions. 42 __module__ =
"lsst.pex.exceptions" 53 super(Exception, self).
__init__(message)
57 return getattr(self.
cpp, name)
60 return "%s('%s')" % (type(self).__name__, self.
cpp.what())
63 return self.
cpp.asString()
127 """Translate a C++ Exception instance to Python and return it.""" 128 PyType = registry.get(type(cpp),
None)
130 warnings.warn(
"Could not find appropriate Python type for C++ Exception")
135 def declare(module, exception_name, base, wrapped_class):
136 """Declare a new exception.""" 138 dict(WrappedClass=wrapped_class))))
def __getattr__(self, name)
def __init__(self, arg, args, kwds)
def declare(module, exception_name, base, wrapped_class)