Skip to content

Commit 7c29c12

Browse files
authored
Merge pull request #395 from intercom/jonny/suspended_app_error
Adding error to catch suspended apps
2 parents d394acd + de8bcd8 commit 7c29c12

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/intercom/errors.rb

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ def to_hash
2727
# Check that you have set Intercom.token correctly.
2828
class AuthenticationError < IntercomError; end
2929

30+
# Raised when the token provided is linked to a deleted application.
31+
class AppSuspendedError < AuthenticationError; end
32+
33+
# Raised when the token provided has been revoked.
34+
class TokenRevokedError < AuthenticationError; end
35+
36+
# Raised when the token provided can't be decoded, and is most likely invalid.
37+
class TokenUnauthorizedError < AuthenticationError; end
38+
3039
# Raised when something goes wrong on within the Intercom API service.
3140
class ServerError < IntercomError; end
3241

lib/intercom/request.rb

+6
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ def raise_application_errors_on_failure(error_list_details, http_code)
152152
case error_code
153153
when 'unauthorized', 'forbidden', 'token_not_found'
154154
raise Intercom::AuthenticationError.new(error_details['message'], error_context)
155+
when 'token_suspended'
156+
raise Intercom::AppSuspendedError.new(error_details['message'], error_context)
157+
when 'token_revoked'
158+
raise Intercom::TokenRevokedError.new(error_details['message'], error_context)
159+
when 'token_unauthorized'
160+
raise Intercom::TokenUnauthorizedError.new(error_details['message'], error_context)
155161
when "bad_request", "missing_parameter", 'parameter_invalid', 'parameter_not_found'
156162
raise Intercom::BadRequestError.new(error_details['message'], error_context)
157163
when "not_restorable"

0 commit comments

Comments
 (0)