Exception: SODA::Exception
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- SODA::Exception
show all
- 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.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response = nil, initial_response_code = nil) ⇒ 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
@message || default_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 default_message
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 @response.code.to_i if @response
@initial_response_code
end
|
94
95
96
|
# File 'lib/soda/exceptions.rb', line 94
def
@response. if @response
end
|
#to_s ⇒ Object
102
103
104
|
# File 'lib/soda/exceptions.rb', line 102
def to_s
message
end
|