Sha256: ccee7eb412b64fad37fee4c447d4e04d50379a083087d3feb3cc880ff66699ba
Contents?: true
Size: 810 Bytes
Versions: 12
Compression:
Stored size: 810 Bytes
Contents
require 'faraday' # @private module Faraday # @private class Response::RaiseHttp5xx < Response::Middleware def on_complete(env) case env[:status].to_i when 500 raise Cashstar::InternalServerError.new(error_message(env, "Something is technically wrong."), env[:response_headers]) when 502 raise Cashstar::BadGateway.new(error_message(env, "Cashstar is down or being upgraded."), env[:response_headers]) when 503 raise Cashstar::ServiceUnavailable.new(error_message(env, "(__-){ Cashstar is over capacity or a service error occured."), env[:response_headers]) end end private def error_message(env, body=nil) "#{env[:method].to_s.upcase} #{env[:url].to_s}: #{[env[:status].to_s + ':', body].compact.join(' ')}" end end end
Version data entries
12 entries across 12 versions & 2 rubygems