hbutils.reflection.exception

Overview:

This module provides utility functions for handling exceptions and traceback objects. It includes functions to print and retrieve full backtrace information from exception objects, which is useful for debugging and error logging purposes.

str_traceback

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

Get full backtrace for exception object as a string.

Parameters:

err (BaseException) – Exception object to extract traceback from.

Returns:

Full string representation of the backtrace.

Return type:

str

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