Sha256: a77bb111722313febb631ccd56fc274c6b67bc68be9de3a108f2f385f3b719b2
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'faraday' module Smartdc module Response class RaiseError < Faraday::Response::Middleware def on_complete(env) case env[:status] when 400 raise Smartdc::Error::BadRequest, response_values(env) when 401 raise Smartdc::Error::Unauthorized, response_values(env) when 403 raise Smartdc::Error::Forbidden, response_values(env) when 404 raise Smartdc::Error::NotFound, response_values(env) when 405 raise Smartdc::Error::MethodNotAllowed, response_values(env) when 406 raise Smartdc::Error::NotAcceptable, response_values(env) when 409 raise Smartdc::Error::Conflict, response_values(env) when 500 raise Smartdc::Error::InternalServerError, response_values(env) when 501 raise Smartdc::Error::NotImplemented, response_values(env) when 502 raise Smartdc::Error::BadGateway, response_values(env) when 503 raise Smartdc::Error::ServiceUnavailable, response_values(env) end end def response_values(env) {:status => env[:status], :headers => env[:response_headers], :body => env[:body]} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smartdc-0.4.0 | lib/smartdc/response/raise_error.rb |