Skip to content

Conversation

@jonnyom
Copy link
Contributor

@jonnyom jonnyom commented May 9, 2018

No description provided.

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)

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
         

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! 👍

}
case error_code
when 'unauthorized', 'forbidden', 'token_not_found'
if error_details['message'].include? 'suspended application'

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?

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'

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?

Copy link
Contributor Author

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'
Copy link
Contributor

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?

Copy link
Contributor Author

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!

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'
Copy link
Contributor

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 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

@jonnyom jonnyom force-pushed the jonny/suspended_app_error branch from de49836 to de8bcd8 Compare May 9, 2018 11:05
Copy link
Contributor

@khalilovcmd khalilovcmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@jonnyom jonnyom merged commit 7c29c12 into master May 9, 2018
@jonnyom jonnyom deleted the jonny/suspended_app_error branch May 9, 2018 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants