Class: Xendify::Middleware::HandleResponseException

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

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/xendify/middleware.rb', line 4

def call(env)
  @app.call(env).on_complete do |response|
    raise Xendify::Errors::ServerError, 'An unexpected error occurred, our team has been notified and will troubleshoot the issue.' if response.status.to_s.start_with?('5')

    validate_response(response.body)
  end
end