Sha256: 098c2386efe0e69391b366496a2c0eaa0ab6920560dd403c4a9b3e13c30bfdf6

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 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 REST
    module Response
      class RaiseError < Faraday::Response::Middleware
        def on_complete(env)
          status_code = env[:status].to_i
          error_class = Twitter::Error.errors[status_code]
          fail error_class.from_response(env) if error_class
        end
      end
    end
  end
end

Faraday::Response.register_middleware :raise_error => Twitter::REST::Response::RaiseError

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter-5.6.0 lib/twitter/rest/response/raise_error.rb