Skip to content

Commit

Permalink
Merge branch 'travekperk-excecptions-pr' of https://github.com/fylein…
Browse files Browse the repository at this point in the history
…/fyle-integrations-settings-api into travelperk-basepr-2
  • Loading branch information
NileshPant1999 committed Dec 5, 2023
2 parents ed22010 + 24a461c commit fcaf1bf
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
26 changes: 26 additions & 0 deletions travelperksdk/__init__.py
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"
44 changes: 44 additions & 0 deletions travelperksdk/exceptions.py
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.

0 comments on commit fcaf1bf

Please sign in to comment.