Sha256: b4c423fff01198bd77261a85e05f722bf014fb93e02ced1ad08036b5332691eb

Contents?: true

Size: 830 Bytes

Versions: 17

Compression:

Stored size: 830 Bytes

Contents

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

module Twitter
  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

17 entries across 17 versions & 1 rubygems

Version Path
twitter-4.8.1 lib/twitter/response/raise_error.rb
twitter-4.8.0 lib/twitter/response/raise_error.rb
twitter-4.7.0 lib/twitter/response/raise_error.rb
twitter-4.6.2 lib/twitter/response/raise_error.rb
twitter-4.6.1 lib/twitter/response/raise_error.rb
twitter-4.6.0 lib/twitter/response/raise_error.rb
twitter-4.5.0 lib/twitter/response/raise_error.rb
twitter-4.4.4 lib/twitter/response/raise_error.rb
twitter-4.4.3 lib/twitter/response/raise_error.rb
twitter-4.4.2 lib/twitter/response/raise_error.rb
twitter-4.4.1 lib/twitter/response/raise_error.rb
twitter-4.4.0 lib/twitter/response/raise_error.rb
twitter-4.3.0 lib/twitter/response/raise_error.rb
twitter-4.2.0 lib/twitter/response/raise_error.rb
twitter-4.1.2 lib/twitter/response/raise_error.rb
twitter-4.1.1 lib/twitter/response/raise_error.rb
twitter-4.1.0 lib/twitter/response/raise_error.rb