Exception: Ac::AcError
- Inherits:
-
StandardError
- Object
- StandardError
- Ac::AcError
- Defined in:
- lib/ac.rb
Direct Known Subclasses
BlockValidationError, NotFoundError, ServerError, TooManyRequestsError, UnauthorizedError, UnprocessableEntityError
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ AcError
constructor
A new instance of AcError.
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ AcError
Returns a new instance of AcError.
35 36 37 |
# File 'lib/ac.rb', line 35 def initialize response @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
34 35 36 |
# File 'lib/ac.rb', line 34 def response @response end |
Class Method Details
.from_response(response) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ac.rb', line 17 def self.from_response response case response.response.code when 401 .new(response) when 404 NotFoundError.new(response) when 422 UnprocessableEntityError.new(response) when 429 TooManyRequestsError.new(response) when 500..599 ServerError.new(response) else AcError.new(response) end end |
Instance Method Details
#to_s ⇒ Object
39 40 41 |
# File 'lib/ac.rb', line 39 def to_s "#{self.class}: #{response.response.code} - #{response.values.present? ? response.inspect : response.response.body}" end |