diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-02-02 21:53:40 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | a1c4b14c8f504b39cfadd78a9010c3ed6495e123 (patch) | |
tree | f4ad95fdf5eb6d05d27e9f1d36736048a5f4ee54 /slack/python_compatibility.py | |
parent | b91385fe3d3538704deb06bb187dc48efa87e34b (diff) | |
download | wee-slack-a1c4b14c8f504b39cfadd78a9010c3ed6495e123.tar.gz |
Record uncaught errors and add command to display them
Diffstat (limited to 'slack/python_compatibility.py')
-rw-r--r-- | slack/python_compatibility.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/slack/python_compatibility.py b/slack/python_compatibility.py index 1590894..e96b8af 100644 --- a/slack/python_compatibility.py +++ b/slack/python_compatibility.py @@ -1,3 +1,7 @@ +import traceback +from typing import List + + # Copied from https://peps.python.org/pep-0616/ for support for Python < 3.9 def removeprefix(self: str, prefix: str) -> str: if self.startswith(prefix): @@ -12,3 +16,7 @@ def removesuffix(self: str, suffix: str) -> str: return self[: -len(suffix)] else: return self[:] + + +def format_exception(exc: BaseException) -> List[str]: + return traceback.format_exception(type(exc), exc, exc.__traceback__) |