12. Annotate exceptions¶
sasmodels.exception¶
Utility to add annotations to python exceptions.
- exception sasmodels.exception.WindowsError¶
Bases:
ExceptionFake WindowsException when not on Windows.
- __cause__¶
- __class__¶
alias of
type
- __context__¶
- __delattr__(name, /)¶
Implement delattr(self, name).
- __dict__ = mappingproxy({'__module__': 'sasmodels.exception', '__firstlineno__': 10, '__doc__': '\nFake WindowsException when not on Windows.\n', '__static_attributes__': (), '__weakref__': <attribute '__weakref__' of 'WindowsError' objects>, '__annotations_cache__': {}})¶
- __dir__()¶
Default dir() implementation.
- __doc__ = '\nFake WindowsException when not on Windows.\n'¶
- __eq__(value, /)¶
Return self==value.
- __firstlineno__ = 10¶
- __format__(format_spec, /)¶
Default object formatter.
Return str(self) if format_spec is empty. Raise TypeError otherwise.
- __ge__(value, /)¶
Return self>=value.
- __getattribute__(name, /)¶
Return getattr(self, name).
- __getstate__()¶
Helper for pickle.
- __gt__(value, /)¶
Return self>value.
- __hash__()¶
Return hash(self).
- __init__(*args, **kwargs)¶
- classmethod __init_subclass__()¶
This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
- __le__(value, /)¶
Return self<=value.
- __lt__(value, /)¶
Return self<value.
- __module__ = 'sasmodels.exception'¶
- __ne__(value, /)¶
Return self!=value.
- classmethod __new__(*args, **kwargs)¶
- __reduce__()¶
Helper for pickle.
- __reduce_ex__(protocol, /)¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__(state, /)¶
- __sizeof__()¶
Size of object in memory, in bytes.
- __static_attributes__ = ()¶
- __str__()¶
Return str(self).
- classmethod __subclasshook__(object, /)¶
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- __suppress_context__¶
- __traceback__¶
- __weakref__¶
list of weak references to the object
- add_note(note, /)¶
Add a note to the exception
- args¶
- with_traceback(tb, /)¶
Set self.__traceback__ to tb and return self.
- sasmodels.exception.annotate_exception(msg, exc=None)¶
Add an annotation to the current exception, which can then be forwarded to the caller using a bare “raise” statement to raise the annotated exception. If the exception exc is provided, then that exception is the one that is annotated, otherwise sys.exc_info is used.
Example:
>>> D = {} >>> try: ... print(D['hello']) ... except: ... annotate_exception("while accessing 'D'") ... raise Traceback (most recent call last): ... KeyError: "hello while accessing 'D'"