Exception: SODA::Exception
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- SODA::Exception
- Defined in:
- lib/soda/exceptions.rb
Overview
This is the base 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, SSLCertificateNotVerified, ServerBrokeConnection
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
- #message ⇒ Object
-
#original_exception ⇒ Object
Returns the value of attribute original_exception.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #default_message ⇒ Object
- #http_body ⇒ Object
- #http_code ⇒ Object
- #http_headers ⇒ Object
-
#initialize(response = nil, initial_response_code = nil) ⇒ Exception
constructor
A new instance of Exception.
- #to_s ⇒ Object
Constructor Details
#initialize(response = nil, initial_response_code = nil) ⇒ Exception
Returns a new instance of Exception.
82 83 84 85 86 |
# File 'lib/soda/exceptions.rb', line 82 def initialize(response = nil, initial_response_code = nil) @response = response @message = nil @initial_response_code = initial_response_code end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
79 80 81 |
# File 'lib/soda/exceptions.rb', line 79 def data @data end |
#message ⇒ Object
106 107 108 |
# File 'lib/soda/exceptions.rb', line 106 def @message || end |
#original_exception ⇒ Object
Returns the value of attribute original_exception.
78 79 80 |
# File 'lib/soda/exceptions.rb', line 78 def original_exception @original_exception end |
#response ⇒ Object
Returns the value of attribute response.
77 78 79 |
# File 'lib/soda/exceptions.rb', line 77 def response @response end |
Instance Method Details
#default_message ⇒ Object
110 111 112 |
# File 'lib/soda/exceptions.rb', line 110 def self.class.name end |
#http_body ⇒ Object
98 99 100 |
# File 'lib/soda/exceptions.rb', line 98 def http_body @response.body if @response end |
#http_code ⇒ Object
88 89 90 91 92 |
# File 'lib/soda/exceptions.rb', line 88 def http_code # return integer for compatibility return @response.code.to_i if @response @initial_response_code end |
#http_headers ⇒ Object
94 95 96 |
# File 'lib/soda/exceptions.rb', line 94 def http_headers @response.headers if @response end |
#to_s ⇒ Object
102 103 104 |
# File 'lib/soda/exceptions.rb', line 102 def to_s end |