Skip to content
PHP Ecosystem
Explore

ExceptionSnapshot

API reference › Debug Core › Storage › ExceptionSnapshot

final readonly classPHPForge\Debug\Storage\ExceptionSnapshot
ImplementsJsonSerializable, Stringable
Sourcesrc/Storage/ExceptionSnapshot.php

Represents a captured throwable without executable state.

MethodDescriptionDefined by
__construct()Frame arguments stay in their tagged form so a snapshot read back from disk re-serializes byte for byte; newly captured snapshots deliberately persist an empty argument list.ExceptionSnapshot
__toString()Returns the original throwable text captured in the snapshot.ExceptionSnapshot
fromArray() staticHydrates a throwable snapshot from decoded JSON data.ExceptionSnapshot
fromThrowable() staticCaptures a throwable and its previous-exception chain without executable state.ExceptionSnapshot
getClass()Returns the captured throwable class.ExceptionSnapshot
getCode()Returns the captured throwable code.ExceptionSnapshot
getFile()Returns the file where the throwable originated.ExceptionSnapshot
getLine()Returns the line where the throwable originated.ExceptionSnapshot
getMessage()Returns the captured throwable message.ExceptionSnapshot
getPrevious()Returns the previous throwable snapshot or null.ExceptionSnapshot
getTrace()Returns the trace frames with their arguments projected to plain display values.ExceptionSnapshot
jsonSerialize()Returns the throwable snapshot for JSON serialization.ExceptionSnapshot
public function __construct(string $class, string $message, int|string $code, string $file, int $line, list<array{namespace: string, short_class: string, class: string, type: string, function: string|null, file: string|null, line: int|null, args: PHPForge\Debug\Storage\DebugArray}> $trace, string $toString, self|null $previous)

Frame arguments stay in their tagged form so a snapshot read back from disk re-serializes byte for byte; newly captured snapshots deliberately persist an empty argument list.

Parameters

ParameterTypeDescription
$classstringCaptured throwable class.
$messagestringCaptured throwable message.
$codeint|stringCaptured throwable code.
$filestringFile where the throwable originated.
$lineintLine where the throwable originated.
$tracelist<array{namespace: string, short_class: string, class: string, type: string, function: string|null, file: string|null, line: int|null, args: DebugArray}>Captured trace frames.
$toStringstringOriginal throwable text.
$previousself|nullPrevious throwable snapshot or null.
public function __toString(): string

Returns the original throwable text captured in the snapshot.

Returns

string: Original throwable text.

public static function fromArray(mixed $data, string $path = '$.exception'): self

Hydrates a throwable snapshot from decoded JSON data.

Parameters

ParameterTypeDescription
$datamixedDecoded throwable payload.
$pathstringPayload path used in hydration errors.

Returns

self: Hydrated throwable snapshot.

public static function fromThrowable(Throwable $throwable): self

Captures a throwable and its previous-exception chain without executable state.

Parameters

ParameterTypeDescription
$throwableThrowableThrowable to capture.

Returns

self: Captured throwable snapshot.

public function getClass(): string

Returns the captured throwable class.

Returns

string: Captured throwable class.

public function getCode(): int|string

Returns the captured throwable code.

Returns

int|string: Captured throwable code.

public function getFile(): string

Returns the file where the throwable originated.

Returns

string: Origin file path.

public function getLine(): int

Returns the line where the throwable originated.

Returns

int: Origin line number.

public function getMessage(): string

Returns the captured throwable message.

Returns

string: Captured throwable message.

public function getPrevious(): self|null

Returns the previous throwable snapshot or null.

Returns

self|null: Previous throwable snapshot or null.

public function getTrace(): list<array<string, mixed>>

Returns the trace frames with their arguments projected to plain display values.

Returns

list<array<string, mixed>>: Display-safe trace frames.

public function jsonSerialize(): array<string, mixed>

Returns the throwable snapshot for JSON serialization.

Returns

array<string, mixed>: Serialized throwable snapshot.