forked from recombee/python-api-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
27 lines (21 loc) · 904 Bytes
/
exceptions.py
File metadata and controls
27 lines (21 loc) · 904 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
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, status_code, description):
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):
super(ApiTimeoutException, self).__init__("ApiTimeout: client did not get response within %s ms" % request.timeout)
self.request = request