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, MaxRedirectsReached, Redirect, SSLCertificateNotVerified, ServerBrokeConnection
Instance Attribute Summary (collapse)
- - (Object) message
-
- (Object) response
Returns the value of attribute response.
Instance Method Summary (collapse)
- - (Object) http_body
- - (Object) http_code
-
- (Exception) initialize(response = nil, initial_response_code = nil)
constructor
A new instance of Exception.
- - (Object) inspect
- - (Object) to_s
Constructor Details
- (Exception) initialize(response = nil, initial_response_code = nil)
A new instance of Exception
86 87 88 89 90 91 92 |
# 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 |
Instance Attribute Details
- (Object) message
115 116 117 |
# File 'lib/restclient/exceptions.rb', line 115 def @message || self.class.name end |
- (Object) response
Returns the value of attribute response
83 84 85 |
# File 'lib/restclient/exceptions.rb', line 83 def response @response end |
Instance Method Details
- (Object) http_body
103 104 105 |
# File 'lib/restclient/exceptions.rb', line 103 def http_body @response.body if @response end |
- (Object) http_code
94 95 96 97 98 99 100 101 |
# 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 |
- (Object) inspect
107 108 109 |
# File 'lib/restclient/exceptions.rb', line 107 def inspect "#{}: #{http_body}" end |
- (Object) to_s
111 112 113 |
# File 'lib/restclient/exceptions.rb', line 111 def to_s inspect end |