Class: EngagingNetworksRest::Response::RaiseError
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- EngagingNetworksRest::Response::RaiseError
- Defined in:
- lib/engaging_networks_rest/response/raise_error.rb
Instance Method Summary collapse
Instance Method Details
#error_message(response) ⇒ Object
24 25 26 |
# File 'lib/engaging_networks_rest/response/raise_error.rb', line 24 def (response) "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]} \n\n #{response[:body] if response[:body]}" end |
#on_complete(response) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/engaging_networks_rest/response/raise_error.rb', line 8 def on_complete(response) status_code = response[:status].to_i if (400...600).include? status_code case status_code when 401 raise Unauthorized.new((response)) when 404 raise NotFound.new((response)) when 500 raise InternalError.new((response)) else raise StandardError.new((response)) end end end |