Class: Booqable::Middleware::RaiseError

Inherits:
Base
  • Object
show all
Defined in:
lib/booqable/middleware/raise_error.rb

Overview

Faraday middleware that raises Booqable exceptions based on HTTP status codes

This middleware automatically converts HTTP error responses into appropriate Booqable exception classes. It inspects the response status code and body to determine the specific error type and raises the corresponding exception.

Examples:

Adding to Faraday middleware stack

builder.use Booqable::Middleware::RaiseError

See Also:

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ void

This method returns an undefined value.

Handle completed HTTP responses and raise exceptions for errors

Called by Faraday after a response is received. Inspects the response and raises an appropriate Booqable exception if the status indicates an error. Successful responses are allowed to pass through unchanged.

Parameters:

  • The HTTP response object

Raises:

  • Various error subclasses based on status code



24
25
26
# File 'lib/booqable/middleware/raise_error.rb', line 24

def on_complete(response)
  Booqable::Error.from_response(response)
end