Created
November 21, 2019 18:50
-
-
Save Shuhala/58dd08a1286503a3d8d3449f1420dfed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import traceback | |
from typing import Optional, Union | |
def format_exception(exception: Optional[Union[Exception, BaseException]]) -> str: | |
""" Format a prettier exception trace """ | |
if exception: | |
return f"\n{type(exception).__name__} Exception: {exception}" f"\n{''.join(traceback.format_tb(exception.__traceback__))}" | |
return " Exception." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment