-
Notifications
You must be signed in to change notification settings - Fork 18
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
impersonate - raise error when non success response is returned #121
Conversation
589d826
to
375ca61
Compare
375ca61
to
4d9262a
Compare
lib/castle/client.rb
Outdated
@@ -81,7 +81,9 @@ def impersonate(options = {}) | |||
options = Castle::Utils.deep_symbolize_keys(options || {}) | |||
add_timestamp_if_necessary(options) | |||
command = Castle::Commands::Impersonate.new(@context).build(options) | |||
@api.request(command) | |||
@api.request(command).tap do |response| | |||
raise Castle::ApiError, 'Impersonate request failed' unless response[:success] |
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.
this should be a custom error.
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.
@mensfeld - corrected
d376e74
to
6b0007a
Compare
@@ -81,7 +81,9 @@ def impersonate(options = {}) | |||
options = Castle::Utils.deep_symbolize_keys(options || {}) | |||
add_timestamp_if_necessary(options) | |||
command = Castle::Commands::Impersonate.new(@context).build(options) | |||
@api.request(command) | |||
@api.request(command).tap do |response| | |||
raise Castle::ImpersonationFailed unless response[:success] |
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.
you could provide a context or some details as a raise argument, it will make debuggng easier.
No description provided.