ThrowableTransformAware
- Full name:
\Codefy\Framework\Traits\ThrowableTransformAware
Properties
exceptionMap
A map of Throwable::class => callable(Throwable): HttpException
Methods
mapException
Register a transformer for a specific Throwable class.
Example: $this->mapException(RecordsNotFoundException::class, fn($e) => new NotFoundHttpException('/x'));
Parameters:
| Parameter | Type | Description |
|---|---|---|
$class | string | |
$transformer | callable |
tryTransformException
Convert a Throwable into an HttpException if a mapping exists.
Otherwise, return null.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$t | \Throwable |
transformToHttpException
Convert unknown exception to HttpException using best-available mapping.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$t | \Throwable |