Sha256: f946b4d7606f8c11f354612007c7ff7cb7c6ce7c03ed3e8a72db3e5d08842c8e

Contents?: true

Size: 614 Bytes

Versions: 6

Compression:

Stored size: 614 Bytes

Contents

# encoding: utf-8

require 'faraday'

require_relative '../error/service_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

6 entries across 6 versions & 3 rubygems

Version Path
github_api2-1.0.1 lib/github_api2/response/raise_error.rb
github_api2-1.0.0 lib/github_api2/response/raise_error.rb
github_api-0.19.0 lib/github_api/response/raise_error.rb
lingfennan-github_api-0.18.2 lib/github_api/response/raise_error.rb
github_api-0.18.2 lib/github_api/response/raise_error.rb
github_api-0.18.1 lib/github_api/response/raise_error.rb