Sha256: a32d9d4d05fd24ee68127a6b74919615c3f34d034895fbb80db1902f525d9435

Contents?: true

Size: 555 Bytes

Versions: 7

Compression:

Stored size: 555 Bytes

Contents

# frozen_string_literal: true

require 'zerobounce/error'

module Zerobounce
  # Faraday middleware.
  module Middleware
    # Raises an error if the response wasn't successful.
    #
    # @author Aaron Frase
    class RaiseError < Faraday::Response::Middleware
      # Check for errors after the response has finished.
      #
      # @param [Hash] env
      # @raise [Error]
      def on_complete(env)
        if (error = Zerobounce::Error.from_response(env)) # rubocop:disable GuardClause
          raise error
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
zerobounce-0.1.1 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.1.0 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.0.6 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.0.5 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.0.4 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.0.3 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.0.2 lib/zerobounce/middleware/raise_error.rb