Class: Response::RaiseArmoryApiError

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/response/raise_armory_api_error.rb

Instance Method Summary collapse

Instance Method Details

#error_message(res) ⇒ Object



15
16
17
# File 'lib/faraday/response/raise_armory_api_error.rb', line 15

def error_message(res)
  "#{res[:method].to_s.upcase} #{res[:url].to_s}: #{res[:body]["reason"]}"
end

#on_complete(res) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/faraday/response/raise_armory_api_error.rb', line 6

def on_complete(res)
  case res[:status].to_i
  when 404
    raise ArmoryApi::NotFound, error_message(res)
  when 500
    raise ArmoryApi::InternalServerError, error_message(res)
  end
end