22 __all__ = [
"register",
"ExceptionMeta",
"Exception",
"LogicError",
23 "DomainError",
"InvalidParameterError",
"LengthError",
24 "OutOfRangeError",
"RuntimeError",
"RangeError",
"OverflowError",
25 "UnderflowError",
"NotFoundError",
"IoError",
"TypeError",
26 "translate",
"declare"]
31 from .
import exceptions
37 """A Python decorator that adds a Python exception wrapper to the registry that maps C++ Exceptions
38 to their Python wrapper classes.
40 registry[cls.WrappedClass] = cls
45 """A metaclass for custom exception wrappers, which adds lookup of class attributes
46 by delegating to the Swig-generated wrapper.
50 return getattr(cls.WrappedClass, name)
54 class Exception(builtins.Exception, metaclass=ExceptionMeta):
55 """The base class for Python-wrapped LSST C++ exceptions.
60 __module__ =
"lsst.pex.exceptions"
70 cpp = self.
WrappedClassWrappedClass(message, *args, **kwds)
71 super(Exception, self).
__init__(message)
75 return getattr(self.
cppcpp, name)
78 return "%s('%s')" % (type(self).__name__, self.
cppcpp.what())
81 return self.
cppcpp.asString()
145 """Translate a C++ Exception instance to Python and return it."""
146 PyType = registry.get(type(cpp),
None)
148 warnings.warn(
"Could not find appropriate Python type for C++ Exception")
153 def declare(module, exception_name, base, wrapped_class):
154 """Declare a new exception."""
156 dict(WrappedClass=wrapped_class))))
Reports arguments outside the domain of an operation.
Provides consistent interface for LSST exceptions.
Reports invalid arguments.
Reports errors in external input/output operations.
Reports attempts to exceed implementation-defined length limits for some classes.
Reports errors in the logical structure of the program.
Reports attempts to access elements using an invalid key.
Reports attempts to access elements outside a valid range of indices.
Reports when the result of an arithmetic operation is too large for the destination type.
Reports when the result of an operation cannot be represented by the destination type.
Reports errors that are due to events beyond the control of the program.
Reports errors from accepting an object of an unexpected or inappropriate type.
Reports when the result of an arithmetic operation is too small for the destination type.
def __getattr__(self, name)
def __init__(self, arg, *args, **kwds)
def declare(module, exception_name, base, wrapped_class)