Exception
Less than 1 minute
Exception
Custom Exception class that extends the base \Exception and implements \JsonSerializable.
Provides a standardized way to handle exceptions with additional support for JSON serialization.
Properties
class
protected string $classtrace
Standard stack trace.
protected array $traceMethods
__construct
Constructs a new exception instance.
public __construct(string $message, int $code = 500, ?\Throwable $previousException): voidParameters
| Parameter | Type | Description |
|---|---|---|
$message | string | the Exception message to throw |
$code | int | the Exception code (defaults to 500 if not provided or if less than or equal to 0) |
$previousException | \Throwable | the previous throwable used for exception chaining |
jsonSerialize
Serializes the exception data to an array suitable for JSON encoding.
public jsonSerialize(): voidThe returned array always includes:
- 'timestamp': The current Unix timestamp with microseconds.
- 'code': The exception code.
- 'message': The exception message.
If the 'display_errors' INI setting is enabled, the array also includes:
- 'file': The filename where the exception was thrown.
- 'line': The line number where the exception was thrown.
- 'class': The class name of the exception.
- 'trace': The stack trace as an array.
getClass
public getClass(): stringgetStackTrace
Returns the stack trace as an array.
public getStackTrace(): voidIf a previous exception was provided during construction, its stack trace is returned. Otherwise, the standard stack trace of this exception is returned.
Generated by Hazaar API Doc Generator on Sun, 01 Mar 2026 09:22:25 +0000