Skip to content

Commit

Permalink
feat: add additional error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Oct 7, 2020
1 parent 7628312 commit d7aaf0e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/rapid_api/errors/request_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ def initialize(client, status, body)
@client = client
@status = status
@body = body

@error = @body['error']
end

def code
@error['code']
end

def description
@error['description']
end

def detail
@error['detail'] || {}
end

end
Expand Down
3 changes: 3 additions & 0 deletions spec/specs/lib/rapid_api/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
request = RapidAPI::Get.new('missing-route')
expect { client.request(request) }.to raise_error RapidAPI::RequestError do |e|
expect(e.status).to eq 404
puts e.body.inspect
expect(e.code).to eq 'route_not_found'
expect(e.description).to eq "No route matches 'missing-route' for GET"
end
end

Expand Down

0 comments on commit d7aaf0e

Please # to comment.