# PanelFailure

> Captures a panel failure without invalidating the remaining request snapshot.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Storage](/docs/extensions/debug-core/reference/storage/index.md) › PanelFailure

| final readonly class | `PHPForge\Debug\Storage\PanelFailure` |
| --- | --- |
| Implements | [`JsonSerializable`](https://www.php.net/manual/en/class.jsonserializable.php) |
| Source | [`src/Storage/PanelFailure.php`](https://github.com/php-forge/debug-core/blob/main/src/Storage/PanelFailure.php#L13) |

Captures a panel failure without invalidating the remaining request snapshot.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-exception"></span>`$exception` readonly constructor | [`ExceptionSnapshot`](/docs/extensions/debug-core/reference/storage/exceptionsnapshot/index.md) | Captured panel exception. | `PanelFailure` |
| <span id="property-stage"></span>`$stage` readonly constructor | `"capture"\|"hydrate"` | Lifecycle stage the panel failed in. | `PanelFailure` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a panel failure record. | `PanelFailure` |
| [`fromArray()`](#method-fromArray) static | Hydrates a panel failure from decoded JSON data. | `PanelFailure` |
| [`fromThrowable()`](#method-fromThrowable) static | Captures a throwable raised during a panel lifecycle stage. | `PanelFailure` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the failure record for JSON serialization. | `PanelFailure` |

## Constants

| Constant | Value | Description | Defined by |
| --- | --- | --- | --- |
| <span id="const-CAPTURE"></span>`CAPTURE` | `'capture'` | Lifecycle stage indicating the panel was captured. | `PanelFailure` |
| <span id="const-HYDRATE"></span>`HYDRATE` | `'hydrate'` | Lifecycle stage indicating the panel was hydrated. | `PanelFailure` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct("capture"|"hydrate" $stage, PHPForge\Debug\Storage\ExceptionSnapshot $exception)
```

Creates a panel failure record.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$stage` | `"capture"\|"hydrate"` | Lifecycle stage the panel failed in. |
| `$exception` | [`ExceptionSnapshot`](/docs/extensions/debug-core/reference/storage/exceptionsnapshot/index.md) | Captured panel exception. |

### fromArray() <span id="method-fromArray"></span>

```php
public static function fromArray(mixed $data, string $path): self
```

Hydrates a panel failure from decoded JSON data.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Decoded panel failure payload. |
| `$path` | `string` | Payload path used in hydration errors. |

**Returns**

`self`: Hydrated panel failure.

### fromThrowable() <span id="method-fromThrowable"></span>

```php
public static function fromThrowable("capture"|"hydrate" $stage, Throwable $throwable): self
```

Captures a throwable raised during a panel lifecycle stage.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$stage` | `"capture"\|"hydrate"` | Lifecycle stage the panel failed in. |
| `$throwable` | [`Throwable`](https://www.php.net/manual/en/class.throwable.php) | Panel exception to capture. |

**Returns**

`self`: Captured panel failure.

### jsonSerialize() <span id="method-jsonSerialize"></span>

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

Returns the failure record for JSON serialization.

**Returns**

`array<string, mixed>`: Serialized failure stage and exception.