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.10.1 lib/github_api/response/raise_error.rb
github_api-0.10.0 lib/github_api/response/raise_error.rb
github_api-0.9.7 lib/github_api/response/raise_error.rb
github_api-0.9.6 lib/github_api/response/raise_error.rb
github_api-0.9.5 lib/github_api/response/raise_error.rb
github_api-0.9.4 lib/github_api/response/raise_error.rb
github_api-0.9.3 lib/github_api/response/raise_error.rb
github_api-0.9.2 lib/github_api/response/raise_error.rb
github_api-0.9.1 lib/github_api/response/raise_error.rb
github_api-0.9.0 lib/github_api/response/raise_error.rb
github_api-0.8.11 lib/github_api/response/raise_error.rb
github_api-0.8.10 lib/github_api/response/raise_error.rb
github_api-0.8.9 lib/github_api/response/raise_error.rb
github_api-0.8.8 lib/github_api/response/raise_error.rb
github_api-0.8.7 lib/github_api/response/raise_error.rb
github_api-0.8.6 lib/github_api/response/raise_error.rb
github_api-0.8.5 lib/github_api/response/raise_error.rb
github_api-0.8.4 lib/github_api/response/raise_error.rb
github_api-0.8.3 lib/github_api/response/raise_error.rb
github_api-0.8.2 lib/github_api/response/raise_error.rb