From a1c4b14c8f504b39cfadd78a9010c3ed6495e123 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Thu, 2 Feb 2023 21:53:40 +0100 Subject: Record uncaught errors and add command to display them --- slack/python_compatibility.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'slack/python_compatibility.py') 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__) -- cgit