Sha256: c5ad71985fce0522967b9d2b2b41b620c0d615583a8b03f304a5be59e6dfc154
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
require 'faraday' require 'multi_json' module Faraday class Response::RaiseHttpError < Response::Middleware def on_complete(response) case response[:status].to_i when 400 raise Lelylan::BadRequest, error_message(response) when 401 raise Lelylan::Unauthorized, error_message(response) when 403 raise Lelylan::Forbidden, error_message(response) when 404 raise Lelylan::NotFound, error_message(response) when 406 raise Lelylan::NotAcceptable, error_message(response) when 422 raise Lelylan::UnprocessableEntity, error_message(response) when 500 raise Lelylan::InternalServerError, error_message(response) when 501 raise Lelylan::NotImplemented, error_message(response) when 502 raise Lelylan::BadGateway, error_message(response) when 503 raise Lelylan::ServiceUnavailable, error_message(response) end end def error_message(response) response[:body] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lelylan-rb-0.0.3 | lib/faraday/response/raise_http_error.rb |
lelylan-rb-0.0.2 | lib/faraday/response/raise_http_error.rb |
lelylan-rb-0.0.1 | lib/faraday/response/raise_http_error.rb |