LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Classes | Functions | Variables
lsst.pex.exceptions.wrappers Namespace Reference

Classes

class  DomainError
 
class  Exception
 
class  ExceptionMeta
 
class  InvalidParameterError
 
class  IoError
 
class  LengthError
 
class  LogicError
 
class  NotFoundError
 
class  OutOfRangeError
 
class  OverflowError
 
class  RangeError
 
class  RuntimeError
 
class  TypeError
 
class  UnderflowError
 

Functions

def register (cls)
 
def translate (cpp)
 
def declare (module, exception_name, base, wrapped_class)
 

Variables

dictionary registry = {}
 

Function Documentation

◆ declare()

def lsst.pex.exceptions.wrappers.declare (   module,
  exception_name,
  base,
  wrapped_class 
)
Declare a new exception.

Definition at line 152 of file wrappers.py.

152 def declare(module, exception_name, base, wrapped_class):
153  """Declare a new exception."""
154  setattr(module, exception_name, register(ExceptionMeta(exception_name, (base, ),
155  dict(WrappedClass=wrapped_class))))
156 
def declare(module, exception_name, base, wrapped_class)
Definition: wrappers.py:152

◆ register()

def lsst.pex.exceptions.wrappers.register (   cls)
A Python decorator that adds a Python exception wrapper to the registry that maps C++ Exceptions
to their Python wrapper classes.

Definition at line 35 of file wrappers.py.

35 def register(cls):
36  """A Python decorator that adds a Python exception wrapper to the registry that maps C++ Exceptions
37  to their Python wrapper classes.
38  """
39  registry[cls.WrappedClass] = cls
40  return cls
41 
42 

◆ translate()

def lsst.pex.exceptions.wrappers.translate (   cpp)
Translate a C++ Exception instance to Python and return it.

Definition at line 143 of file wrappers.py.

143 def translate(cpp):
144  """Translate a C++ Exception instance to Python and return it."""
145  PyType = registry.get(type(cpp), None)
146  if PyType is None:
147  warnings.warn("Could not find appropriate Python type for C++ Exception")
148  PyType = Exception
149  return PyType(cpp)
150 
151 
table::Key< int > type
Definition: Detector.cc:167

Variable Documentation

◆ registry

dictionary lsst.pex.exceptions.wrappers.registry = {}

Definition at line 32 of file wrappers.py.