DXNError
extends RuntimeException
in package
One exception type for every `dextrin` failure mode -- text-parse, printing, and (in later phases) binary/schema failures alike -- so a caller never has to special-case which pipeline produced it.
Unlike Elixir's {:ok, _} | {:error, %Dextrin.Error}} tuples,
throwing here is simply idiomatic PHP from the start (same as the
JS port's own deliberate divergence, for the same reason) -- no
"divergence from tuples" note is needed the way the JS port's own
DXNError doc carries one.
Table of Contents
Properties
Methods
- __construct() : mixed
- wrap() : self
- Wraps any thrown exception from the text/binary pipelines into a `DXNError`, preserving a lexer/parser's own `offset` when present (via the `HasOffset` interface) and passing everything else through as the previous exception -- callers only ever need to catch one exception type from `Dextrin::decode()`/ `Dextrin::encode()`.
Properties
$offset read-only
public
int|null
$offset
$stage read-only
public
string
$stage
Methods
__construct()
public
__construct(string $message[, string $stage = 'unknown' ][, int|null $offset = null ][, Throwable|null $previous = null ]) : mixed
Parameters
- $message : string
- $stage : string = 'unknown'
- $offset : int|null = null
- $previous : Throwable|null = null
wrap()
Wraps any thrown exception from the text/binary pipelines into a `DXNError`, preserving a lexer/parser's own `offset` when present (via the `HasOffset` interface) and passing everything else through as the previous exception -- callers only ever need to catch one exception type from `Dextrin::decode()`/ `Dextrin::encode()`.
public
static wrap(Throwable $err, string $stage) : self
Parameters
- $err : Throwable
- $stage : string