Sha256: 5a58e0108b7fabdb7f31f6f94b5e9a9ffe7cac9dbcbaa5eaf85539ab00aac7e1

Contents?: true

Size: 830 Bytes

Versions: 4

Compression:

Stored size: 830 Bytes

Contents

require 'faraday'
require 'wayback/error/bad_gateway'
require 'wayback/error/bad_request'
require 'wayback/error/forbidden'
require 'wayback/error/gateway_timeout'
require 'wayback/error/internal_server_error'
require 'wayback/error/not_acceptable'
require 'wayback/error/not_found'
require 'wayback/error/service_unavailable'
require 'wayback/error/too_many_requests'
require 'wayback/error/unauthorized'
require 'wayback/error/unprocessable_entity'

module Wayback
  module Response
    class RaiseError < Faraday::Response::Middleware

      def on_complete(env)
        status_code = env[:status].to_i
        error_class = @klass.errors[status_code]
        raise error_class.from_response(env) if error_class
      end

      def initialize(app, klass)
        @klass = klass
        super(app)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wayback-0.3.1 lib/wayback/response/raise_error.rb
wayback-0.2.1 lib/wayback/response/raise_error.rb
wayback-0.2.0 lib/wayback/response/raise_error.rb
wayback-0.1.0 lib/wayback/response/raise_error.rb