hbutils.reflection.exception¶
- Overview:
Useful functions to deal with exception or backtrace objects.
print_traceback¶
-
hbutils.reflection.exception.
print_traceback
(err: BaseException, file=None)[source]¶ - Overview:
Print full backtrace for exception object.
- Arguments:
err (
BaseException
): Exception object.file: Output file, default is
None
which means stdout.
- Examples::
See
str_traceback()
for actual print content.
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