WorkOS PHP SDK

NotFoundException extends BaseRequestException
in package

Base exception thrown for any HTTP error response from the WorkOS API.

Subclasses are mapped 1:1 to HTTP status codes (e.g. 400 -> BadRequestException). Catch this class to handle all API errors uniformly, or a specific subclass to branch on status.

Table of Contents

Properties

$error  : string|null
$errorCode  : string|null
$rawBody  : array<string|int, mixed>|null
$requestId  : string|null
$statusCode  : int|null

Methods

__construct()  : mixed
fromResponse()  : static
Build an exception of the called class from a parsed JSON error response.

Properties

$errorCode read-only

public string|null $errorCode = null

$rawBody read-only

public array<string|int, mixed>|null $rawBody = null

$requestId read-only

public string|null $requestId = null

$statusCode read-only

public int|null $statusCode = null

Methods

__construct()

public __construct([string $message = '' ][, int|null $statusCode = null ][, string|null $requestId = null ][, Throwable|null $previous = null ][, string|null $errorCode = null ][, string|null $error = null ][, array<string, mixed>|null $rawBody = null ]) : mixed
Parameters
$message : string = ''

Human-readable error message, sourced from the response body's message field when present.

$statusCode : int|null = null

HTTP status code of the error response.

$requestId : string|null = null

Value of the X-Request-ID response header, if any. Useful when reporting issues to WorkOS support.

$previous : Throwable|null = null

Previous throwable (e.g. the underlying Guzzle exception).

$errorCode : string|null = null

Machine-readable code from the response body's code field.

$error : string|null = null

Short error identifier from the response body's error field.

$rawBody : array<string, mixed>|null = null

Full decoded JSON error body, or null if the response was empty or non-JSON. Lets callers access fields the SDK doesn't promote to first-class properties (e.g. pending_authentication_token, email, email_verification_id from headless AuthKit).

fromResponse()

Build an exception of the called class from a parsed JSON error response.

public static fromResponse(int $statusCode, array<string, mixed> $body[, string|null $requestId = null ]) : static
Parameters
$statusCode : int

HTTP status code.

$body : array<string, mixed>

Decoded JSON response body.

$requestId : string|null = null

Value of the X-Request-ID header, if any.

Return values
static
On this page

Search results