Oihana PHP Arango

ArangoException extends Exception

Base exception thrown by the ArangoDB client.

Carries:

  • the application-level message (Exception::getMessage()),
  • the HTTP status returned by the server, exposed via Exception::getCode(),
  • the ArangoDB internal error number (errorNum), independent of the HTTP status,
  • a hint indicating whether the failed operation is safe to retry.

Subclasses are expected to override isSafeToRetry() when the underlying error condition is known to be transient (write-write conflicts, cluster maintenance windows, throttling, …).

Tags
see
https://docs.arangodb.com/stable/develop/error-codes-and-meanings/
author

Marc Alcaraz (ekameleon)

since
1.0.0

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

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
ArangoException

isSafeToRetry()

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.

Return values
bool
On this page

Search results