Exception: RestClient::Exception
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- RestClient::Exception
- Defined in:
- lib/restclient/exceptions.rb
Overview
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.
Direct Known Subclasses
ExceptionWithResponse, Redirect, SSLCertificateNotVerified, ServerBrokeConnection
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #http_body ⇒ Object
- #http_code ⇒ Object
-
#initialize(response = nil) ⇒ Exception
constructor
A new instance of Exception.
- #inspect ⇒ Object
Constructor Details
#initialize(response = nil) ⇒ Exception
Returns a new instance of Exception.
63 64 65 66 67 68 |
# File 'lib/restclient/exceptions.rb', line 63 def initialize response = nil @response = response # compatibility: this make the exception behave like a Net::HTTPResponse response.extend ResponseForException if response end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
61 62 63 |
# File 'lib/restclient/exceptions.rb', line 61 def @message end |
#response ⇒ Object
Returns the value of attribute response.
61 62 63 |
# File 'lib/restclient/exceptions.rb', line 61 def response @response end |
Instance Method Details
#http_body ⇒ Object
75 76 77 |
# File 'lib/restclient/exceptions.rb', line 75 def http_body @response.body end |
#http_code ⇒ Object
70 71 72 73 |
# File 'lib/restclient/exceptions.rb', line 70 def http_code # return integer for compatibility @response.code.to_i if @response end |
#inspect ⇒ Object
79 80 81 |
# File 'lib/restclient/exceptions.rb', line 79 def inspect "#{self.class} : #{http_code} #{}" end |