Sha256: 8b20d55ba53c3d03e9c29aae2c23028403b0f2f87d13c4b8287320376c53c7df
Contents?: true
Size: 796 Bytes
Versions: 4
Compression:
Stored size: 796 Bytes
Contents
require 'faraday' # Provides us protection against the FiveMobilePush API's error handling which # is currently incomplete. module Faraday class Response::Errors < Response::Middleware def call(env) @app.call(env).on_complete do case env[:status] when 400 raise FiveMobilePush::GeneralError, response_values(env) when 401 raise FiveMobilePush::UnauthorizedError, response_values(env) when 500 env[:body] = 'push.fivemobile.com is currently down' raise FiveMobilePush::ServerError, response_values(env) end end end # Copied from Faraday def response_values(env) { :status => env[:status], :headers => env[:response_headers], :body => env[:body] } end end end
Version data entries
4 entries across 4 versions & 1 rubygems