Skip to content

Commit

Permalink
Merge pull request #13 from journy-io/forbidden-disabled-api-key
Browse files Browse the repository at this point in the history
Add status codes for disabled api key and unprocessable entities
  • Loading branch information
hansott authored Jun 29, 2021
2 parents 90cd5e2 + 7969f95 commit 4420446
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions journyio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class APIError(Enum):
TooManyRequests = 4, "TooManyRequests"
NotFoundError = 5, "NotFoundError"
UnknownError = 6, "UnknownError"
ForbiddenError = 7, "ForbiddenError"
UnprocessableError = 8, "Unprocessable"


class JournyException(Exception):
Expand All @@ -24,10 +26,12 @@ def __str__(self):


status_code_to_api_error_mapping = defaultdict(lambda: APIError.UnknownError)
status_code_to_api_error_mapping.update({401: APIError.UnauthorizedError,
400: APIError.BadArgumentsError,
429: APIError.TooManyRequests,
status_code_to_api_error_mapping.update({400: APIError.BadArgumentsError,
401: APIError.UnauthorizedError,
403: APIError.ForbiddenError,
404: APIError.NotFoundError,
422: APIError.UnprocessableError,
429: APIError.TooManyRequests,
500: APIError.ServerError})


Expand Down

0 comments on commit 4420446

Please sign in to comment.