Exception: Fluence::Gateway::RequestError

Inherits:
Error
  • Object
show all
Defined in:
lib/fluence/gateway/errors.rb

Overview

Raised when the target service responded with a 4xx/5xx HTTP status.

Wraps the underlying OAuth2::Error but hides the OAuth2 dependency from callers and exposes status, body, and headers directly so consumers don't need to reach into error.response.*.

Examples:

Handle not-found specifically

begin
  Fluence::Gateway::Client.get('/api/v1/thing', service: :base_valeur)
rescue Fluence::Gateway::RequestError => e
  return nil if e.status == 404
  raise
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, response: nil) ⇒ RequestError

Builds a new RequestError wrapping the given message and optional response. Callers typically do not call this directly — the gateway client raises it automatically when the target service returns 4xx/5xx.

Parameters:

  • message (String)

    human-readable error message

  • response (#status, #body, #headers, nil) (defaults to: nil)

    the OAuth2::Response (or any duck-typed equivalent) that triggered the error

Instance Attribute Details

#bodyString? (readonly)

Returns the raw response body of the failed response.

Returns:

  • (String, nil)

    raw response body, or nil if no response was attached

#headersHash? (readonly)

Returns the response headers of the failed response.

Returns:

  • (Hash, nil)

    response headers, or nil if no response was attached

#statusInteger? (readonly)

Returns the HTTP status code of the failed response.

Returns:

  • (Integer, nil)

    HTTP status code, or nil if no response was attached