This is the base RestClient exception class. Rescue it if you want to catch any exception that your request might raise You can get the status code by e.http_code, or see anything about the response via e.response. For example, the entire result body (which is probably an HTML error page) is e.response.
# File lib/restclient/exceptions.rb, line 86 def initialize response = nil, initial_response_code = nil @response = response @initial_response_code = initial_response_code # compatibility: this make the exception behave like a Net::HTTPResponse response.extend ResponseForException if response end
# File lib/restclient/exceptions.rb, line 103 def http_body @response.body if @response end
# File lib/restclient/exceptions.rb, line 94 def http_code # return integer for compatibility if @response @response.code.to_i else @initial_response_code end end
# File lib/restclient/exceptions.rb, line 107 def inspect "#{message}: #{http_body}" end
# File lib/restclient/exceptions.rb, line 115 def message @message || self.class.name end
# File lib/restclient/exceptions.rb, line 111 def to_s inspect end