Sha256: 765fff0af72b4c74a81e1709d7816132c25f070e560166959ad2d465bf4d274a

Contents?: true

Size: 459 Bytes

Versions: 9

Compression:

Stored size: 459 Bytes

Contents

require "faraday/response"
require_relative "../error"

module Redd
  # The module that contains middleware that alters the Faraday response.
  module Response
    # Faraday Middleware that raises an error if there's one.
    # @see Error
    class RaiseError < Faraday::Response::Middleware
      def on_complete(env)
        error = Redd::Error.from_response(env)
        fail error.new(env), env[:body] if error
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
redd-0.7.8 lib/redd/response/raise_error.rb
redd-0.7.7 lib/redd/response/raise_error.rb
redd-0.7.6 lib/redd/response/raise_error.rb
redd-0.7.5 lib/redd/response/raise_error.rb
redd-0.7.4 lib/redd/response/raise_error.rb
redd-0.7.3 lib/redd/response/raise_error.rb
redd-0.7.2 lib/redd/response/raise_error.rb
redd-0.7.1 lib/redd/response/raise_error.rb
redd-0.7.0 lib/redd/response/raise_error.rb