HttpException extends ArangoException
Thrown when an HTTP request to the ArangoDB server fails with a non-2xx response that does not map to a more specific {@see ArangoException} subclass.
Use this for generic server-side failures (4xx/5xx) that do not carry an Arango internal error number, or when the parser cannot recognise the response shape.
Tags
Table of Contents
Properties
- $errorNum : int|null
Methods
- __construct() : mixed
- Creates a new ArangoException instance.
- fromResponse() : ArangoException
- Builds the appropriate {@see ArangoException} subclass from a parsed ArangoDB error response.
- isSafeToRetry() : bool
- Indicates whether the failed operation is safe to retry as-is.
Properties
$errorNum read-only
public
int|null
$errorNum
= null
Methods
__construct()
Creates a new ArangoException instance.
public
__construct([string $message = '' ][, int|null $errorNum = null ][, int $httpStatus = 0 ][, Throwable|null $previous = null ]) : mixed
Parameters
- $message : string = ''
-
Human-readable message returned by the server (or constructed locally).
- $errorNum : int|null = null
-
ArangoDB internal error number (for example 1200 for a write-write conflict). Null when the failure did not produce an Arango code.
- $httpStatus : int = 0
-
HTTP status returned by the server (0 when the call never reached the server).
- $previous : Throwable|null = null
-
Previous exception in the chain (network failure, decoding error, …).
fromResponse()
Builds the appropriate {@see ArangoException} subclass from a parsed ArangoDB error response.
public
static fromResponse(int $httpStatus[, array<string|int, mixed> $body = [] ][, Throwable|null $previous = null ]) : ArangoException
The factory inspects the errorNum field of the response body and
dispatches to a dedicated subclass when the code is known. The HTTP
status is preserved on the resulting exception (exposed via
getCode()).
Expected body shape (server-provided):
{ "error": true, "code": 404, "errorNum": 1202, "errorMessage": "document not found" }
Parameters
- $httpStatus : int
-
HTTP status returned by the server.
- $body : array<string|int, mixed> = []
-
Decoded JSON body (may be empty when the server returned no body).
- $previous : Throwable|null = null
-
Previous exception in the chain (typically the Guzzle exception).
Return values
ArangoExceptionisSafeToRetry()
Indicates whether the failed operation is safe to retry as-is.
public
isSafeToRetry() : bool
The base implementation returns false. Subclasses representing transient errors (conflicts, cluster maintenance, throttling, …) MUST override this method to return true.