-
Notifications
You must be signed in to change notification settings - Fork 5
API Exceptions ClientThrowable
Base interface for all OpenFGA SDK exceptions. Extends the standard PHP Throwable interface with additional methods to provide detailed context about SDK-specific errors including HTTP request/response information and categorized error types. This interface ensures consistent error handling across all exception types in the OpenFGA SDK, enabling developers to access rich context information for debugging and error reporting. All OpenFGA exceptions implement this interface to provide a unified error handling experience. OpenFGA exceptions are categorized into specific types: - Authentication errors (token expired, invalid credentials) - Configuration errors (missing PSR components, invalid setup) - Network errors (HTTP failures, timeouts, API unavailability) - Serialization errors (JSON parsing, schema validation failures) - Client errors (general validation and usage errors)
Table of Contents
OpenFGA\Exceptions
ThrowableStringable
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.
array<string, mixed> — Associative array of context data including parameter values, error details, and debugging information
public function getCode()public function getFile(): stringstring
public function getLine(): intint
public function getMessage(): stringstring
public function getPrevious(): ?ThrowableThrowable | null
public function getTrace(): arrayarray
public function getTraceAsString(): stringstring
public function kind(): AuthenticationError|ClientError|ConfigurationError|NetworkError|SerializationErrorGet 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.
AuthenticationError | ClientError | ConfigurationError | NetworkError | SerializationError — The error category enum indicating the type of failure
public function previous(): Throwable|nullGet 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.
Throwable | null — The previous exception in the chain, or null if this is the root exception
public function request(): RequestInterface|nullGet 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.
RequestInterface | null — The PSR-7 HTTP request that triggered the exception, or null if not applicable
public function response(): ResponseInterface|nullGet 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.
ResponseInterface | null — The PSR-7 HTTP response received from the API, or null if no response was received
Getting Started: Introduction • Installation • Authentication
Essentials: Stores • Authorization Models • Relationship Tuples • Permissions Queries
Features: Helper Functions • Concurrency • Results • Exceptions • Observability • Integration
- API Reference - Full class and method documentation
- Quickstart - Get up and running in minutes
- Helpers - Convenient shortcuts for common operations
- Testing Guide - Unit testing with the SDK
- Performance Guide - Optimize for high-scale applications
- Report Issues - Bug reports and feature requests
- Discussions - Community support and questions
- Contributing - Help improve the SDK
- Changelog - Latest updates and releases
- OpenFGA Documentation - Official OpenFGA documentation
- OpenFGA Playground - Interactive modeling environment
- Authorization Concepts - Learn relationship-based access control
- Other SDKs - JavaScript, Go, Python, .NET, and more
OpenFGA PHP SDK • Apache 2.0 License
- Authorization Stores
- Authorization Models
- Relationship Tuples
- Permission Queries
- Testing with Assertions
- Helper Functions
- Concurrency
- Error Handling
- Framework Integration
- OpenTelemetry Observability
- Result Pattern
- Event Dispatcher
- HTTP Request Sent Event
- HTTP Response Received Event
- Operation Started Event
- Operation Completed Event
- More Events …
- Authentication Exception
- Client Exception
- Configuration Exception
- Network Exception
- Serialization Exception
- More Exceptions …
- Request Manager
- Request Context
- Circuit Breaker
- Parallel Task Executor
- Fiber Concurrent Executor
- Simple Concurrent Executor
- Retry Handler
- Exponential Backoff Retry Strategy
- More Networking …