Sha256: 85182f057156d1e49f25f0afb0c9f5f771778448ca3df51ed131315b64ede86b

Contents?: true

Size: 494 Bytes

Versions: 26

Compression:

Stored size: 494 Bytes

Contents

# encoding: utf-8

require 'faraday'
require 'github_api/error'

module Github
  class Response::RaiseError < Faraday::Response::Middleware

    def on_complete(env)
      status_code = env[:status].to_i
      service_error = Github::Error::ServiceError
      error_class = service_error.errors[status_code]
      error_class = service_error if !error_class and (400...600).include? status_code
      raise error_class.new(env) if error_class
    end

  end # Response::RaiseError
end # Github

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
github_api-0.8.1 lib/github_api/response/raise_error.rb
github_api-0.8.0 lib/github_api/response/raise_error.rb
github_api-0.7.2 lib/github_api/response/raise_error.rb
github_api-0.7.1 lib/github_api/response/raise_error.rb
github_api-0.7.0 lib/github_api/response/raise_error.rb
github_api-0.6.5 lib/github_api/response/raise_error.rb