Skip to content

Instantly share code, notes, and snippets.

View prcongithub's full-sized avatar

Prashant Chaudhari prcongithub

View GitHub Profile
@prcongithub
prcongithub / FaradayExceptions.rb
Created June 24, 2013 11:46
Faraday Exceptions
module Faraday
class Response::RaiseError < Response::Middleware
ClientErrorStatuses = 400...600
def on_complete(env)
case env[:status]
when 404
raise Faraday::Error::ResourceNotFound, response_values(env)
when 422
raise Faraday::Error::UnprocessableEntity, response_values(env)