class RestClient::Exception
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.
Attributes
message[W]
response[RW]
Public Class Methods
new(response = nil, initial_response_code = nil)
click to toggle source
# File lib/restclient/exceptions.rb, line 91 def initialize response = nil, initial_response_code = nil @response = response @message = nil @initial_response_code = initial_response_code # compatibility: this make the exception behave like a Net::HTTPResponse response.extend ResponseForException if response end
Public Instance Methods
http_body()
click to toggle source
# File lib/restclient/exceptions.rb, line 109 def http_body @response.body if @response end
http_code()
click to toggle source
# File lib/restclient/exceptions.rb, line 100 def http_code # return integer for compatibility if @response @response.code.to_i else @initial_response_code end end
inspect()
click to toggle source
# File lib/restclient/exceptions.rb, line 113 def inspect "#{message}: #{http_body}" end
message()
click to toggle source
# File lib/restclient/exceptions.rb, line 121 def message @message || self.class.name end
to_s()
click to toggle source
# File lib/restclient/exceptions.rb, line 117 def to_s inspect end