Sha256: cbee72260bb9d41093efe7954de4a877c85b34cb66eb84c319fa6b654d23a3c6

Contents?: true

Size: 545 Bytes

Versions: 8

Compression:

Stored size: 545 Bytes

Contents

require 'faraday'
require 'flattr/error/bad_gateway'
require 'flattr/error/internal_server_error'

module Flattr
  module Response
    class RaiseServerError < Faraday::Response::Middleware

      def on_complete(env)
        case env[:status].to_i
        when 500
          raise Flattr::Error::InternalServerError.new("Something is technically wrong.", env[:response_headers])
        when 502
          raise Flattr::Error::BadGateway.new("Flattr is down or being upgraded.", env[:response_headers])
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
flattr-0.3.7 lib/flattr/response/raise_server_error.rb
flattr-0.3.6 lib/flattr/response/raise_server_error.rb
flattr-0.3.5 lib/flattr/response/raise_server_error.rb
flattr-0.3.4 lib/flattr/response/raise_server_error.rb
flattr-0.3.3 lib/flattr/response/raise_server_error.rb
flattr-0.3.2 lib/flattr/response/raise_server_error.rb
flattr-0.3.1 lib/flattr/response/raise_server_error.rb
flattr-0.3.0 lib/flattr/response/raise_server_error.rb