Skip to content

Commit

Permalink
feat: add string for request errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Oct 7, 2020
1 parent d7aaf0e commit d108150
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/rapid_api/errors/request_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ def initialize(client, status, body)
@error = @body['error']
end

def to_s
string = ["[#{@status}]"]
if code && description
string << "#{code}: #{description}"
elsif code
string << code
else
string << @body
end
string.join(' ')
end

def code
@error['code']
end
Expand Down

0 comments on commit d108150

Please # to comment.