Created
November 21, 2019 18:50
-
-
Save Shuhala/aa4d25c3e2dcc9d0a90243145580d011 to your computer and use it in GitHub Desktop.
This file contains 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