Sha256: 0b0a904c04333b3b283cf08ff3891368a624aecb60b5408eb5340417980b928b
Contents?: true
Size: 908 Bytes
Versions: 9
Compression:
Stored size: 908 Bytes
Contents
# -*- encoding: utf-8 -*- require 'faraday' require '<%= project_name %>/exceptions' module <%= root_module %> module Middleware ## Raise beautiful exceptions # class ExceptionRaiser < Faraday::Middleware ## For handling errors, the message that gets returned is of the following format: # {:status => env[:status], :headers => env[:response_headers], :body => env[:body]} def call(env) begin @app.call(env) rescue Faraday::Error::ClientError => e # This is our chance to reinterpret the response into a meaningful, client-specific # exception that a consuming service can handle exception = <%= root_module %>::GenericException raise exception, e.response rescue Saddle::TimeoutError => e raise <%= root_module %>::TimeoutError, e.response end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems