Sha256: 2183f9b6e723fb30352777413135af50e2dfb16852cf549a5590ee70d56d0508
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'faraday' # @api private module Faraday class Response::RaiseError < Response::Middleware def on_complete(response) case response[:status].to_i when 400 raise Octokit::BadRequest, error_message(response) when 401 raise Octokit::Unauthorized, error_message(response) when 403 raise Octokit::Forbidden, error_message(response) when 404 raise Octokit::NotFound, error_message(response) when 406 raise Octokit::NotAcceptable, error_message(response) when 500 raise Octokit::InternalServerError, error_message(response) when 501 raise Octokit::NotImplemented, error_message(response) when 502 raise Octokit::BadGateway, error_message(response) when 503 raise Octokit::ServiceUnavailable, error_message(response) end end def error_message(response) "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]}#{(': ' + response[:body][:error]) if response[:body]}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
octokit-0.6.3 | lib/faraday/response/raise_error.rb |