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, initial_response_code = nil) ⇒ Exception
constructor
A new instance of Exception.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response = nil, initial_response_code = nil) ⇒ Exception
Returns a new instance of Exception.
85 86 87 88 89 90 91 |
# File 'lib/restclient/exceptions.rb', line 85 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 |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
83 84 85 |
# File 'lib/restclient/exceptions.rb', line 83 def @message end |
#response ⇒ Object
Returns the value of attribute response.
83 84 85 |
# File 'lib/restclient/exceptions.rb', line 83 def response @response end |
Instance Method Details
#http_body ⇒ Object
102 103 104 |
# File 'lib/restclient/exceptions.rb', line 102 def http_body @response.body if @response end |
#http_code ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/restclient/exceptions.rb', line 93 def http_code # return integer for compatibility if @response @response.code.to_i else @initial_response_code end end |
#inspect ⇒ Object
106 107 108 |
# File 'lib/restclient/exceptions.rb', line 106 def inspect "#{}: #{http_body}" end |
#to_s ⇒ Object
110 111 112 |
# File 'lib/restclient/exceptions.rb', line 110 def to_s inspect end |