Exception: Rest::HttpError
- Defined in:
- lib/rest/errors.rb
Direct Known Subclasses
Wrappers::InternalClientExceptionWrapper, Wrappers::RestClientExceptionWrapper
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#options ⇒ Object
Returns the value of attribute options.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response, code, options = {}) ⇒ HttpError
constructor
A new instance of HttpError.
- #to_s ⇒ Object
Constructor Details
#initialize(response, code, options = {}) ⇒ HttpError
Returns a new instance of HttpError.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rest/errors.rb', line 13 def initialize(response, code, ={}) super("#{code} Error") @response = response if response && response.body begin bodyparsed = JSON.parse(response.body) @msg = bodyparsed["msg"] rescue => ex # ignore end end @code = code = end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
10 11 12 |
# File 'lib/rest/errors.rb', line 10 def code @code end |
#msg ⇒ Object
Returns the value of attribute msg.
11 12 13 |
# File 'lib/rest/errors.rb', line 11 def msg @msg end |
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/rest/errors.rb', line 11 def end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/rest/errors.rb', line 10 def response @response end |
Instance Method Details
#to_s ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rest/errors.rb', line 28 def to_s s = "HTTP #{code} Error" if @msg s += ": #{@msg}" end s end |