Sha256: d231a8ffee6b0055e66e9bea0fb375b68638c8ef88a770228ac754921190a2a6

Contents?: true

Size: 598 Bytes

Versions: 5

Compression:

Stored size: 598 Bytes

Contents

# encoding: utf-8

require 'faraday'
require 'github_api/error'

module Github
  class Response::RaiseError < Faraday::Response::Middleware
    # Check if status code requires raising a ServiceError
    #
    # @api private
    def on_complete(env)
      status_code   = env[:status].to_i
      service_error = Github::Error::ServiceError
      error_class = service_error.error_mapping[status_code]
      if !error_class and (400...600) === status_code
        error_class = service_error
      end
      raise error_class.new(env) if error_class
    end
  end # Response::RaiseError
end # Github

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
github_api-0.17.0 lib/github_api/response/raise_error.rb
github_api-0.16.0 lib/github_api/response/raise_error.rb
github_api-0.15.0 lib/github_api/response/raise_error.rb
github_api-0.14.5 lib/github_api/response/raise_error.rb
github_api-0.14.4 lib/github_api/response/raise_error.rb