Sha256: 2fbce55fc8b00eadbf0305f0d8406edb46f42851069e9ceb0df42d060f38ca93

Contents?: true

Size: 561 Bytes

Versions: 3

Compression:

Stored size: 561 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 Style/GuardClause
          raise error
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zerobounce-0.2.2 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.2.0 lib/zerobounce/middleware/raise_error.rb
zerobounce-0.1.2 lib/zerobounce/middleware/raise_error.rb