-
Notifications
You must be signed in to change notification settings - Fork 137
Adding error to catch suspended apps #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if error_details['message'].include? 'suspended application' | ||
| raise Intercom::AppSuspendedError.new(error_details['message'], error_context) | ||
| end | ||
| raise Intercom::AuthenticationError.new(error_details['message'], error_context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move raise AuthenticationError into the else block to make it clearer?
+ if error_details['message'].include? 'suspended application'
+ raise Intercom::AppSuspendedError.new(error_details['message'], error_context)
else
raise Intercom::AuthenticationError.new(error_details['message'], error_context)
+ end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! 👍
lib/intercom/request.rb
Outdated
| } | ||
| case error_code | ||
| when 'unauthorized', 'forbidden', 'token_not_found' | ||
| if error_details['message'].include? 'suspended application' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we return suspended application in the response for deleted apps too?
lib/intercom/request.rb
Outdated
| case error_code | ||
| when 'unauthorized', 'forbidden', 'token_not_found' | ||
| raise Intercom::AuthenticationError.new(error_details['message'], error_context) | ||
| if error_details['message'].include? 'suspended application' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we return suspended application in the response for deleted apps too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we do, but I think it might be safer to use the error type instead of the message string!
| case error_code | ||
| when 'unauthorized', 'forbidden', 'token_not_found' | ||
| raise Intercom::AuthenticationError.new(error_details['message'], error_context) | ||
| when 'token_suspended' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want add a check for token_unauthorized and token_revoked too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good shout, my bad!
lib/intercom/request.rb
Outdated
| case error_code | ||
| when 'unauthorized', 'forbidden', 'token_not_found' | ||
| raise Intercom::AuthenticationError.new(error_details['message'], error_context) | ||
| when 'token_suspended', 'token_revoked', 'token_unauthorized' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my thought here was to introduce two new errors for token_revoked and token_unauthorized. Or we can introduce one new error which is generic that can be TokenError. Your call 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
de49836 to
de8bcd8
Compare
khalilovcmd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
No description provided.