Sha256: 0959d7214433aa771ec5cad4c042776d8da57afbff90f9cbc3654a72d1134795

Contents?: true

Size: 801 Bytes

Versions: 17

Compression:

Stored size: 801 Bytes

Contents

# encoding: utf-8

require 'faraday'
require 'github_api/error'

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

    def on_complete(env)
      case env[:status].to_i
      when 400
        raise Github::Error::BadRequest.new(env)
      when 401
        raise Github::Error::Unauthorized.new(env)
      when 403
        raise Github::Error::Forbidden.new(env)
      when 404
        raise Github::Error::NotFound.new(env)
      when 422
        raise Github::Error::UnprocessableEntity.new(env)
      when 500
        raise Github::Error::InternalServerError.new(env)
      when 503
        raise Github::Error::ServiceUnavailable.new(env)
      when 400...600
        raise Github::Error::ServiceError.new(env)
      end
    end

  end # Response::RaiseError
end # Github

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
github_api-0.6.3 lib/github_api/response/raise_error.rb
github_api-0.6.2 lib/github_api/response/raise_error.rb
github_api-0.6.1 lib/github_api/response/raise_error.rb
github_api-0.6.0 lib/github_api/response/raise_error.rb
github_api-0.5.4 lib/github_api/response/raise_error.rb
github_api-0.5.3 lib/github_api/response/raise_error.rb
github_api-0.5.2 lib/github_api/response/raise_error.rb
github_api-0.5.1 lib/github_api/response/raise_error.rb
github_api-0.5.0 lib/github_api/response/raise_error.rb
github_api-0.5.0.rc1 lib/github_api/response/raise_error.rb
github_api-0.4.11 lib/github_api/response/raise_error.rb
github_api-0.4.10 lib/github_api/response/raise_error.rb
github_api-0.4.9 lib/github_api/response/raise_error.rb
github_api-0.4.8 lib/github_api/response/raise_error.rb
github_api-0.4.7 lib/github_api/response/raise_error.rb
github_api-0.4.6 lib/github_api/response/raise_error.rb
github_api-0.4.5 lib/github_api/response/raise_error.rb