forked from justoneapi/justoneapi-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_exceptions.py
More file actions
27 lines (16 loc) · 712 Bytes
/
_exceptions.py
File metadata and controls
27 lines (16 loc) · 712 Bytes
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
from __future__ import annotations
from typing import Any
from justoneapi._response import ApiResponse
class JustOneAPIError(Exception):
"""Base exception for the SDK."""
class TransportError(JustOneAPIError):
"""Raised when an HTTP transport error occurs."""
class ProtocolError(JustOneAPIError):
"""Raised when the server response cannot be interpreted."""
class BusinessError(JustOneAPIError):
"""Raised when the API returns a non-zero business code and error raising is enabled."""
def __init__(self, response: ApiResponse[Any]):
super().__init__(
response.message or f"Request failed with code={response.code!r}"
)
self.response = response