Skip to content

Commit

Permalink
changed ApiError to NonSuccessError for non success impersonate
Browse files Browse the repository at this point in the history
  • Loading branch information
bartes committed Apr 17, 2018
1 parent 4d9262a commit d376e74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/castle/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def impersonate(options = {})
add_timestamp_if_necessary(options)
command = Castle::Commands::Impersonate.new(@context).build(options)
@api.request(command).tap do |response|
raise Castle::ApiError, 'Impersonate request failed' unless response[:success]
raise Castle::NonSuccessError, 'Impersonate request failed' unless response[:success]
end
end

Expand Down
2 changes: 2 additions & 0 deletions lib/castle/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ class InvalidParametersError < Castle::ApiError; end
class UnauthorizedError < Castle::ApiError; end
# all internal server errors
class InternalServerError < Castle::ApiError; end
# non success response
class NonSuccessError < Castle::ApiError; end
end
2 changes: 1 addition & 1 deletion spec/lib/castle/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
let(:response_body) { {}.to_json }

it do
expect { client.impersonate(options) }.to raise_error(Castle::ApiError)
expect { client.impersonate(options) }.to raise_error(Castle::NonSuccessError)
end
end
end
Expand Down

0 comments on commit d376e74

Please sign in to comment.