Skip to content

Commit

Permalink
feat: handle hash of errors in response
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 27, 2017
1 parent 314e2e2 commit fff32c2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/pact_broker/client/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ def handle_response response
else
error_message = nil
begin
error_message = JSON.parse(response.body)['errors'].join("\n")
errors = JSON.parse(response.body)['errors']
error_message = if errors.is_a?(Array)
errors.join("\n")
elsif errors.is_a?(Hash)
errors.collect{ |key, value| "#{key}: #{value}" }.join("\n")
else
response.body
end
rescue
raise Error.new(response.body)
end
Expand Down

0 comments on commit fff32c2

Please sign in to comment.