better_trace ============ .. py:module:: better_trace Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/better_trace/__main__/index /autoapi/better_trace/_did_you_mean/index /autoapi/better_trace/better_trace/index /autoapi/better_trace/cli/index Functions --------- .. autoapisummary:: better_trace.initialize better_trace.demo better_trace.revert Package Contents ---------------- .. py:function:: 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 "", line 1, in sayori NameError: name 'sayori' is not defined ``` ## 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 .. py:function:: 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!") ZeroDivisionError: You tried to divide by 0! ``` ## Notes: - This function just showcases the traceback formatting - To actually get the traceback formatting, call initialize .. py:function:: 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 "", line 1, in 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 "", line 1, in oyasumi NameError: name 'oyasumi' is not defined ``` ## 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