Sha256: 44b7ab5ad8dadea7c15b8956ba9fa68165c6bff89405583e8e084f515a29201d

Contents?: true

Size: 675 Bytes

Versions: 4

Compression:

Stored size: 675 Bytes

Contents

require 'faraday'
require 'multi_json'

# @api private
module Faraday
  class Response::RaiseOctokitError < Response::Middleware
    ERROR_MAP = {
      400 => Octokit::BadRequest,
      401 => Octokit::Unauthorized,
      403 => Octokit::Forbidden,
      404 => Octokit::NotFound,
      406 => Octokit::NotAcceptable,
      422 => Octokit::UnprocessableEntity,
      500 => Octokit::InternalServerError,
      501 => Octokit::NotImplemented,
      502 => Octokit::BadGateway,
      503 => Octokit::ServiceUnavailable
    }

    def on_complete(response)
      key = response[:status].to_i
      raise ERROR_MAP[key].new(response) if ERROR_MAP.has_key? key
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
octokit-1.25.0 lib/faraday/response/raise_octokit_error.rb
octokit-1.24.0 lib/faraday/response/raise_octokit_error.rb
octokit-1.23.0 lib/faraday/response/raise_octokit_error.rb
octokit-1.22.0 lib/faraday/response/raise_octokit_error.rb