Errors
NAME
Turborel\TurborelException: the driver's one error.
SYNOPSIS
class TurborelException extends \RuntimeException
{
public function __construct(string $message, string $sqlState, int $sqlCode, ?\Throwable $previous = null);
public function getSqlState(): string;
public function getSqlCode(): int;
public function getRule(): ?string;
public function getPosition(): int|string|null;
public function isTransactionActive(): ?bool;
public function getDiagnostics(): array;
public function endsConnection(): bool;
}
DESCRIPTION
Every failure the driver gives is a TurborelException, whether the
server reported it or the driver found it. getSqlState gives its
SQLSTATE, five characters; getSqlCode its SQLCODE, negative for an
error; getMessage what it is, for people; getPrevious its cause, if
it had one.
A failure the server reported says more. getRule gives the rule of a
standard it cites, as X3.135-1986 §6.4 GR2; getPosition where in
the statement it is, in characters; isTransactionActive whether the
session's transaction is active after it, none of a failure the driver
found; getDiagnostics, granted diagnostics, its fields by name:
severity, detail, hint, context, schema, table, column,
dataType and constraint, each that is known. A failure the driver
found gives its severity alone: FATAL if it ends the connection, else
ERROR, as turborel-client's do. A statement's
conditions, takeConditions, are TurborelExceptions too, of class 01
or 02, never thrown.
endsConnection tells whether the failure lost its connection: a
connection exception, class 08 but 08003, or credentials refused as the
connection is made, class 28 of SQLCODE -919.
ERRORS
The failures the driver raises itself:
| SQLSTATE | SQLCODE | When |
|---|---|---|
| 08006 | -919 | The server not reached; TLS failing; a wait run out; a reply's frame malformed, or a reply out of turn; a capability not granted |
| 28000 | -919 | A secret over plain TCP; SCRAM's exchange refused |
| 22003 | -301 | A number, or a field's value, out of its range |
| 22021 | -301 | A string that is not UTF-8 |
| 22032 | -301 | JSON text that does not parse |
| TB916 | -916 | A value the driver cannot take: a JSON stored form that is damaged; of a reply, a truth or units byte not 0 or 1, a malformed condition, value tags 18 and 19, its statement failing alone, the connection kept |
| 0A000 | -900 | JSON past turborel's limits: nested more than 128 deep, or a stored form past 256 MiB; of a reply, its statement failing alone |
| 2200N | -301 | An XML value's text that is not well-formed content, as nodes() parses it |
| 22000 | -301 | A PHP value the protocol has no value for |
EXAMPLES
On $connection, a Connection:
try {
$connection->query('SELECT * FROM NOPE');
} catch (Turborel\TurborelException $failure) {
echo $failure->getSqlState(), ' ', $failure->getSqlCode(), ' at ', $failure->getPosition(), ': ', $failure->getMessage(), PHP_EOL;
echo $failure->getRule(), ', ends the connection: ', var_export($failure->endsConnection(), true), PHP_EOL;
}
2A000 -103 at 14: table ANN.NOPE is not defined
X3.135-1986 §5.4 SR5, ends the connection: false
STANDARD
[PROTOCOL Error 'E'], [PROTOCOL Errors and notices], [CLIENT Running statements], [CLIENT What the server tells].