Sha256: 5a67428412ab698e76bc33770ee74c36c7560ea70d2f192f1b0a3c2547ae5909
Contents?: true
Size: 549 Bytes
Versions: 7
Compression:
Stored size: 549 Bytes
Contents
module Vertebrae module Response class RaiseError < Faraday::Response::Middleware def on_complete(response) status_code = response[:status].to_i if (400...600).include? status_code raise StandardError.new(error_message(response)) end end def error_message(response) "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]} \n\n #{response[:body] if response[:body]}" end end class NotFound < StandardError ; end end # Response::RaiseError end
Version data entries
7 entries across 7 versions & 1 rubygems