Skip to content

Commit 60b1413

Browse files
tanasegabrieljkeyes
authored andcommitted
Extended error handling
Handle additional error codes.
1 parent 164fd6c commit 60b1413

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

intercom/errors.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class RateLimitExceeded(IntercomError):
4545
pass
4646

4747

48+
class ResourceNotRestorable(IntercomError):
49+
pass
50+
51+
4852
class MultipleMatchingUsersError(IntercomError):
4953
pass
5054

@@ -57,6 +61,10 @@ class TokenUnauthorizedError(IntercomError):
5761
pass
5862

5963

64+
class TokenNotFoundError(IntercomError):
65+
pass
66+
67+
6068
error_codes = {
6169
'unauthorized': AuthenticationError,
6270
'forbidden': AuthenticationError,
@@ -65,10 +73,19 @@ class TokenUnauthorizedError(IntercomError):
6573
'missing_parameter': BadRequestError,
6674
'parameter_invalid': BadRequestError,
6775
'parameter_not_found': BadRequestError,
76+
'client_error': BadRequestError,
77+
'type_mismatch': BadRequestError,
6878
'not_found': ResourceNotFound,
79+
'admin_not_found': ResourceNotFound,
80+
'not_restorable': ResourceNotRestorable,
6981
'rate_limit_exceeded': RateLimitExceeded,
7082
'service_unavailable': ServiceUnavailableError,
83+
'server_error': ServiceUnavailableError,
7184
'conflict': MultipleMatchingUsersError,
7285
'unique_user_constraint': MultipleMatchingUsersError,
73-
'token_unauthorized': TokenUnauthorizedError
86+
'token_unauthorized': TokenUnauthorizedError,
87+
'token_not_found': TokenNotFoundError,
88+
'token_revoked': TokenNotFoundError,
89+
'token_blocked': TokenNotFoundError,
90+
'token_expired': TokenNotFoundError
7491
}

0 commit comments

Comments
 (0)