class Exception extends Exception implements Throwable (View source)

Exception class.

Methods

__construct(string $message, int|string $code = 0, Throwable|null $previous = null)

Exception constructor.

string
__toString()

Returns a string representation of the exception object.

static void
handle(Closure $callback, string|null $message = null, int $level = E_ALL)

Handles the passed callback in a safe context where PHP errors (and exceptions) result in exceptions that can be caught.

static never
throw(string $message, int|string $code = 0, Throwable|null $previous = null)

Throws an exception using the class this method was called on.

Details

__construct(string $message, int|string $code = 0, Throwable|null $previous = null)

Exception constructor.

{@inheritDoc}

Parameters

string $message

Exception message.

int|string $code

Exception code.

Throwable|null $previous

string __toString()

Returns a string representation of the exception object.

Return Value

string

static void handle(Closure $callback, string|null $message = null, int $level = E_ALL)

Handles the passed callback in a safe context where PHP errors (and exceptions) result in exceptions that can be caught.

Parameters

Closure $callback

The callback to execute.

string|null $message

[optional] The exception message if the callback raised an error or throw an exception.

int $level

[optional] The error level to handle. E_* constant, the behavior is unexpected if an arbitrary value is specified.

Return Value

void

Exceptions

Exception

static never throw(string $message, int|string $code = 0, Throwable|null $previous = null)

Throws an exception using the class this method was called on.

Parameters

string $message

[optional] Exception message.

int|string $code

[optional] Exception code. The code will be casted to an integer.

Throwable|null $previous

[optional] Previous exception.

Return Value

never

Exceptions

Exception