Exception: RestClient::Exception
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- RestClient::Exception
show all
- 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.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response = nil, initial_response_code = nil) ⇒ Exception
Returns a new instance of Exception.
114
115
116
117
118
|
# File 'lib/restclient/exceptions.rb', line 114
def initialize response = nil, initial_response_code = nil
@response = response
@message = nil
@initial_response_code = initial_response_code
end
|
Instance Attribute Details
#message ⇒ Object
141
142
143
|
# File 'lib/restclient/exceptions.rb', line 141
def message
@message || default_message
end
|
#original_exception ⇒ Object
Returns the value of attribute original_exception.
111
112
113
|
# File 'lib/restclient/exceptions.rb', line 111
def original_exception
@original_exception
end
|
#response ⇒ Object
Returns the value of attribute response.
110
111
112
|
# File 'lib/restclient/exceptions.rb', line 110
def response
@response
end
|
Instance Method Details
#default_message ⇒ Object
145
146
147
|
# File 'lib/restclient/exceptions.rb', line 145
def default_message
self.class.name
end
|
#http_body ⇒ Object
133
134
135
|
# File 'lib/restclient/exceptions.rb', line 133
def http_body
@response.body if @response
end
|
#http_code ⇒ Object
120
121
122
123
124
125
126
127
|
# File 'lib/restclient/exceptions.rb', line 120
def http_code
if @response
@response.code.to_i
else
@initial_response_code
end
end
|
129
130
131
|
# File 'lib/restclient/exceptions.rb', line 129
def
@response. if @response
end
|
#to_s ⇒ Object
137
138
139
|
# File 'lib/restclient/exceptions.rb', line 137
def to_s
message
end
|