aboutsummaryrefslogtreecommitdiffstats
path: root/slack/error.py
blob: 17427f72397880c24a73a36a2343b79e3b31b672 (plain) (blame)
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
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Mapping, Union

if TYPE_CHECKING:
    from slack_api.slack_error import SlackErrorResponse

    from slack.slack_workspace import SlackWorkspace


class HttpError(Exception):
    def __init__(
        self,
        url: str,
        options: Dict[str, str],
        return_code: int,
        http_status_code: int,
        error: str,
    ):
        super().__init__()
        self.url = url
        self.options = options
        self.return_code = return_code
        self.http_status_code = http_status_code
        self.error = error


class SlackApiError(Exception):
    def __init__(
        self,
        workspace: SlackWorkspace,
        method: str,
        response: SlackErrorResponse,
        params: Mapping[str, Union[str, int, bool]] = {},
    ):
        super().__init__()
        self.workspace = workspace
        self.method = method
        self.params = params
        self.response = response