UnprocessableEntityException
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
$error read-only
public
string|null
$error
= null
$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
messagefield when present. - $statusCode : int|null = null
-
HTTP status code of the error response.
- $requestId : string|null = null
-
Value of the
X-Request-IDresponse 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
codefield. - $error : string|null = null
-
Short error identifier from the response body's
errorfield. - $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_idfrom 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-IDheader, if any.