-
Notifications
You must be signed in to change notification settings - Fork 841
/
Copy path__init__.py
58 lines (37 loc) · 1.86 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Errors that can be raised by this SDK"""
class SlackClientError(Exception):
"""Base class for Client errors"""
class BotUserAccessError(SlackClientError):
"""Error raised when an 'xoxb-*' token is
being used for a Slack API method that only accepts 'xoxp-*' tokens.
"""
class SlackRequestError(SlackClientError):
"""Error raised when there's a problem with the request that's being submitted."""
class SlackApiError(SlackClientError):
"""Error raised when Slack does not send the expected response.
Attributes:
response (SlackResponse): The SlackResponse object containing all of the data sent back from the API.
Note:
The message (str) passed into the exception is used when
a user converts the exception to a str.
i.e. str(SlackApiError("This text will be sent as a string."))
"""
def __init__(self, message, response):
msg = f"{message}\nThe server responded with: {response}"
self.response = response
super(SlackApiError, self).__init__(msg)
class SlackTokenRotationError(SlackClientError):
"""Error raised when the oauth.v2.access call for token rotation fails"""
api_error: SlackApiError
def __init__(self, api_error: SlackApiError):
self.api_error = api_error
class SlackClientNotConnectedError(SlackClientError):
"""Error raised when attempting to send messages over the websocket when the
connection is closed."""
class SlackObjectFormationError(SlackClientError):
"""Error raised when a constructed object is not valid/malformed"""
class SlackClientConfigurationError(SlackClientError):
"""Error raised because of invalid configuration on the client side:
* when attempting to send messages over the websocket when the connection is closed.
* when external system (e.g., Amazon S3) configuration / credentials are not correct
"""