-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'travekperk-excecptions-pr' of https://github.com/fylein…
…/fyle-integrations-settings-api into travelperk-basepr-2
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
TravelPerk init | ||
""" | ||
from .exceptions import ( | ||
TravelperkSDKError, | ||
NotFoundError, | ||
InternalServerError, | ||
RateLimitError, | ||
UnauthorizedClientError, | ||
BadRequestError, | ||
ForbiddenClientError | ||
) | ||
|
||
|
||
__all__ = [ | ||
'TravelperkSDKError', | ||
'NotFoundError', | ||
'UnauthorizedClientError', | ||
'RateLimitError', | ||
'InvalidTokenError', | ||
'BadRequestError', | ||
'InternalServerError', | ||
'ForbiddenClientError' | ||
] | ||
|
||
name = "travelperksdk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
TravelPerk SDK Exceptions | ||
""" | ||
|
||
|
||
class TravelperkSDKError(Exception): | ||
"""The base exception class for Travelperk. | ||
Parameters: | ||
msg (str): Short description of the error. | ||
response: Error response from the API call. | ||
""" | ||
|
||
def __init__(self, msg, response=None): | ||
super(TravelperkSDKError, self).__init__(msg) | ||
self.message = msg | ||
self.response = response | ||
|
||
def __str__(self): | ||
return repr(self.message) | ||
|
||
|
||
class UnauthorizedClientError(TravelperkSDKError): | ||
"""Wrong client secret and/or refresh token, 401 error.""" | ||
|
||
|
||
class ForbiddenClientError(TravelperkSDKError): | ||
"""The user has insufficient privilege, 403 error.""" | ||
|
||
|
||
class BadRequestError(TravelperkSDKError): | ||
"""Some of the parameters are wrong, 400 error.""" | ||
|
||
|
||
class NotFoundError(TravelperkSDKError): | ||
"""Not found the item from URL, 404 error.""" | ||
|
||
|
||
class InternalServerError(TravelperkSDKError): | ||
"""The rest TravelperkSDK errors, 500 error.""" | ||
|
||
|
||
class RateLimitError(TravelperkSDKError): | ||
"""To many requests, 429 error.""" |
Empty file.
Empty file.