API Exceptions NetworkException - evansims/openfga-php GitHub Wiki

Network-related exception for the OpenFGA SDK. Thrown when network or HTTP communication errors occur while interacting with the OpenFGA API. Includes specific HTTP status code errors, request failures, timeouts, and other network-related issues. Provides access to both the HTTP request and response for detailed debugging.

Table of Contents


Namespace

OpenFGA\Exceptions


Source

View source code


Implements


Methods

context

public function context(): array<string, mixed>

Get additional context information about the exception. Provides access to contextual data that was available when the exception occurred, such as parameter values, configuration details, API response data, or other relevant debugging information. This context is essential for understanding the circumstances that led to the error and can be used for logging, debugging, and error reporting.

View source


Returns

array&lt;string, mixed&gt; — Associative array of context data including parameter values, error details, and debugging information


getCode

public function getCode()

getFile

public function getFile(): string

Returns

string


getLine

public function getLine(): int

Returns

int


getMessage

public function getMessage(): string

Returns

string


getPrevious

public function getPrevious(): ?Throwable

Returns

Throwable | null


getTrace

public function getTrace(): array

Returns

array


getTraceAsString

public function getTraceAsString(): string

Returns

string


kind

public function kind(): OpenFGA\Exceptions\ClientError|OpenFGA\Exceptions\AuthenticationError|OpenFGA\Exceptions\ConfigurationError|OpenFGA\Exceptions\NetworkError|OpenFGA\Exceptions\SerializationError

Get the specific error category for this exception. Returns the error classification that indicates the general category of the problem (authentication, configuration, network, etc.), allowing for categorized error handling and reporting. This categorization helps applications implement appropriate retry logic, user messaging, and error recovery strategies based on the type of failure.

View source


Returns

ClientError | AuthenticationError | ConfigurationError | NetworkError | SerializationError — The error category enum indicating the type of failure


previous

public function previous(): ?Throwable

Get the previous exception that caused this one. Provides access to the exception chain for cases where this exception was triggered by another underlying exception. This maintains the full context of error propagation and is essential for root cause analysis when exceptions are wrapped or transformed during processing.

View source


Returns

Throwable | null — The previous exception in the chain, or null if this is the root exception


request

public function request(): ?Psr\Http\Message\RequestInterface

Get the HTTP request associated with this exception. Returns the PSR-7 HTTP request that was being processed when this exception occurred. This is particularly useful for debugging API call failures, allowing developers to inspect the request URL, headers, body, and method that led to the error condition.

View source


Returns

Psr\Http\Message\RequestInterface | null — The PSR-7 HTTP request that triggered the exception, or null if not applicable


response

public function response(): ?Psr\Http\Message\ResponseInterface

Get the HTTP response associated with this exception. Returns the PSR-7 HTTP response that was received when this exception occurred, providing access to status codes, headers, and response body for debugging. This is especially valuable for understanding API-level failures and can contain detailed error messages from the OpenFGA service.

View source


Returns

Psr\Http\Message\ResponseInterface | null — The PSR-7 HTTP response received from the API, or null if no response was received

⚠️ **GitHub.com Fallback** ⚠️