Exception: Ac::AcError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/ac.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#responseObject (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
    UnauthorizedError.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_sObject



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