12. Annotate exceptions¶
sasmodels.exception
¶
Utility to add annotations to python exceptions.
- exception sasmodels.exception.WindowsError¶
Bases:
Exception
Fake WindowsException when not on Windows.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- 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'"