hbutils.reflection.exception

Overview:

Useful functions to deal with exception or backtrace objects.

str_traceback

hbutils.reflection.exception.str_traceback(err: BaseException) → str[source]
Overview:

Get full backtrace for exception object.

Arguments:
  • err (BaseException): Exception object.

Returns:
  • backtrace (str): Full string backtrace.

Examples:
>>> try:
>>>     raise RuntimeError('runtime error')
>>> except RuntimeError as e:
>>>     s = str_traceback(e)
>>> s
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
    raise RuntimeError('runtime error')
RuntimeError: runtime error