-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexceptions.py
More file actions
39 lines (26 loc) · 1.01 KB
/
exceptions.py
File metadata and controls
39 lines (26 loc) · 1.01 KB
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
from recombee_api_client.api_requests import Request
class APIException(Exception):
"""
Base class for exceptions that occur because of errors in requests reported by API or because of a timeout
"""
pass
class ResponseException(APIException):
"""
Exception which is thrown when response status code is not 200 or 201
"""
def __init__(self, request: Request, status_code: int, description: str):
super(ResponseException, self).__init__(
"status: %s, description: %s" % (status_code, description)
)
self.request = request
self.status_code = status_code
self.description = description
class ApiTimeoutException(APIException):
"""
Exception which is thrown when a request is not processed within the timeout
"""
def __init__(self, request: Request):
super(ApiTimeoutException, self).__init__(
"ApiTimeout: client did not get response within %s ms" % request.timeout
)
self.request = request