better_trace¶
Submodules¶
Functions¶
|
initialize() sets sys.excepthook, threading.excepthook and sys.unraisablehook to the custom hook |
|
demo() is a function that intentionally raises a ZeroDivisionError to show the formatting of the traceback |
|
revert() is used to revert the traceback, back to the original traceback |
Package Contents¶
- better_trace.initialize(*, show_locals=True, log_exceptions=False, debugger=False, mode='verbose', theme='monokai', background_color='default', use_config=False) None¶
initialize() sets sys.excepthook, threading.excepthook and sys.unraisablehook to the custom hook Returns:
None
- Example:
``` >>> from better_trace import initialize >>> initialize() >>> sayori ———–An error occurred———– File “<python-input-2>”, line 1, in <module>
sayori
- ## Used by:
sys.excepthook, threading.excepthook, and sys.unraisablehook
- ## Notes:
Use it like this - initialize() and not like this - sys.excepthook = initialize or threading.excepthook = initialize
This function is the opposite to revert, if you want to revert back to the original traceback, call revert
- better_trace.demo() None¶
demo() is a function that intentionally raises a ZeroDivisionError to show the formatting of the traceback Returns:
None
- Example:
``` >>> from better_trace import demo >>> demo() ———–An error occurred———– File “…/better_trace.py”, line …, in demo
raise ZeroDivisionError(“You tried to divide by 0!”)
- ## Notes:
This function just showcases the traceback formatting
To actually get the traceback formatting, call initialize
- better_trace.revert() None¶
revert() is used to revert the traceback, back to the original traceback Returns:
None
- Example:
``` >>> from better_trace import initialize, revert >>> initialize() >>> oyasumi # good night in japanese, also raises an error ———–An error occurred———– File “<python-input-2>”, line 1, in <module>
oyasumi # good night in japanese, also raises an error
NameError: name ‘oyasumi’ is not defined Did you mean: sum? >>> revert() # reverts the custom traceback format to the original traceback >>> oyasumi Traceback (most recent call last):
- File “<python-input-4>”, line 1, in <module>
oyasumi
- ## Notes:
This function reverts sys.excepthook, threading.excepthook, and sys.unraisablehook to sys.__excepthook__, threading.__excepthook__, and sys.__unraisablehook__
This function is the opposite of initialize. If you want the custom formatting, call initialize