aboutsummaryrefslogtreecommitdiffstats
path: root/slack/error.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-01-29 01:29:45 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commitaafa5218281ba2510a025c0c67ddd6caa244bca3 (patch)
treef886f1bfe5a13cb1d78b9b77db36d6aa626383d3 /slack/error.py
parent95f05c435a4db808ab490e42b063aa54f3cb2a2e (diff)
downloadwee-slack-aafa5218281ba2510a025c0c67ddd6caa244bca3.tar.gz
Handle user group fetch error
Diffstat (limited to 'slack/error.py')
-rw-r--r--slack/error.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/slack/error.py b/slack/error.py
index 1d9a975..ed42ca8 100644
--- a/slack/error.py
+++ b/slack/error.py
@@ -46,6 +46,15 @@ class SlackApiError(Exception):
self.response = response
+class SlackError(Exception):
+ def __init__(self, workspace: SlackWorkspace, error: str):
+ super().__init__(
+ f"{self.__class__.__name__}: workspace={workspace}, error={error}"
+ )
+ self.workspace = workspace
+ self.error = error
+
+
def format_exception(e: BaseException):
if isinstance(e, HttpError):
return (
@@ -57,5 +66,7 @@ def format_exception(e: BaseException):
f"Error from Slack API method {e.method} with params {e.params} for workspace "
f"{e.workspace.name}: {e.response}"
)
+ elif isinstance(e, SlackError):
+ return f"Error occurred in workspace {e.workspace.name}: {e.error}"
else:
return f"Unknown error occurred: {e.__class__.__name__}: {e}"