Skip to content

Commit

Permalink
Extended error handling
Browse files Browse the repository at this point in the history
Handle additional error codes.
  • Loading branch information
tanasegabriel authored and jkeyes committed Oct 24, 2017
1 parent 164fd6c commit 60b1413
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion intercom/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class RateLimitExceeded(IntercomError):
pass


class ResourceNotRestorable(IntercomError):
pass


class MultipleMatchingUsersError(IntercomError):
pass

Expand All @@ -57,6 +61,10 @@ class TokenUnauthorizedError(IntercomError):
pass


class TokenNotFoundError(IntercomError):
pass


error_codes = {
'unauthorized': AuthenticationError,
'forbidden': AuthenticationError,
Expand All @@ -65,10 +73,19 @@ class TokenUnauthorizedError(IntercomError):
'missing_parameter': BadRequestError,
'parameter_invalid': BadRequestError,
'parameter_not_found': BadRequestError,
'client_error': BadRequestError,
'type_mismatch': BadRequestError,
'not_found': ResourceNotFound,
'admin_not_found': ResourceNotFound,
'not_restorable': ResourceNotRestorable,
'rate_limit_exceeded': RateLimitExceeded,
'service_unavailable': ServiceUnavailableError,
'server_error': ServiceUnavailableError,
'conflict': MultipleMatchingUsersError,
'unique_user_constraint': MultipleMatchingUsersError,
'token_unauthorized': TokenUnauthorizedError
'token_unauthorized': TokenUnauthorizedError,
'token_not_found': TokenNotFoundError,
'token_revoked': TokenNotFoundError,
'token_blocked': TokenNotFoundError,
'token_expired': TokenNotFoundError
}

0 comments on commit 60b1413

Please sign in to comment.