Class: Zerobounce::Middleware::RaiseHttpException

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/zerobounce/middleware/raise_http_exception.rb

Overview

Raises an error if the response wasn’t successful.

Author:

  • Aaron Frase

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object

Check for errors after the response has finished.

Parameters:

  • env (Hash)

Raises:



16
17
18
19
20
# File 'lib/zerobounce/middleware/raise_http_exception.rb', line 16

def on_complete(env)
  if (error = Zerobounce::Error.from_response(env)) # rubocop:disable Style/GuardClause
    raise error
  end
end