Exception: Rest::InternalClient::Exception
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Rest::InternalClient::Exception
show all
- Defined in:
- lib/rest/wrappers/internal_client/internal/exceptions.rb
Overview
This is the base InternalClient 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.
87
88
89
90
91
92
93
94
|
# File 'lib/rest/wrappers/internal_client/internal/exceptions.rb', line 87
def initialize response = nil, initial_response_code = nil
@response = response
@message = nil
@initial_response_code = initial_response_code
response.extend ResponseForException if response
end
|
Instance Attribute Details
#message ⇒ Object
117
118
119
|
# File 'lib/rest/wrappers/internal_client/internal/exceptions.rb', line 117
def message
@message || self.class.name
end
|
#response ⇒ Object
Returns the value of attribute response.
84
85
86
|
# File 'lib/rest/wrappers/internal_client/internal/exceptions.rb', line 84
def response
@response
end
|
Instance Method Details
#http_body ⇒ Object
105
106
107
|
# File 'lib/rest/wrappers/internal_client/internal/exceptions.rb', line 105
def http_body
@response.body if @response
end
|
#http_code ⇒ Object
96
97
98
99
100
101
102
103
|
# File 'lib/rest/wrappers/internal_client/internal/exceptions.rb', line 96
def http_code
if @response
@response.code.to_i
else
@initial_response_code
end
end
|
#inspect ⇒ Object
109
110
111
|
# File 'lib/rest/wrappers/internal_client/internal/exceptions.rb', line 109
def inspect
"#{message}: #{http_body}"
end
|
#to_s ⇒ Object
113
114
115
|
# File 'lib/rest/wrappers/internal_client/internal/exceptions.rb', line 113
def to_s
inspect
end
|