Oihana PHP Arango

NetworkException extends ArangoException

Thrown when the request cannot reach the server (DNS failure, TCP refused, connect/read timeout, TLS handshake error, …) — that is, before any HTTP response is received.

The default retry safety is conservative (false): retrying a POST that timed out may produce a duplicate write if the server actually processed the request. The retry policy at transport level decides per-method.

Tags
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