class Handler (View source)

Properties

protected ResponsePreparerInterface $responsePreparer

The response preparer implementation.

protected ExceptionDisplayerInterface $plainDisplayer

The plain exception displayer.

protected ExceptionDisplayerInterface $debugDisplayer

The debug exception displayer.

protected bool $debug

Indicates if the application is in debug mode.

protected array $handlers

All of the register exception handlers.

protected array $handled

All of the handled error messages.

Methods

void
__construct(ResponsePreparerInterface $responsePreparer, ExceptionDisplayerInterface $plainDisplayer, ExceptionDisplayerInterface $debugDisplayer, bool $debug = true)

Create a new error handler instance.

void
register(string $environment)

Register the exception / error handlers for the application.

void
registerErrorHandler()

Register the PHP error handler.

void
registerExceptionHandler()

Register the PHP exception handler.

void
registerShutdownHandler()

Register the PHP shutdown handler.

handleError(int $level, string $message, string $file = '', int $line = 0, array $context = array())

Handle a PHP error for the application.

Response
handleException(Exception $exception)

Handle an exception for the application.

void
handleUncaughtException(Exception $exception)

Handle an uncaught exception.

void
handleShutdown()

Handle the PHP shutdown event.

bool
isFatal(int $type)

Determine if the error type is fatal.

void
handleConsole(Exception $exception)

Handle a console exception.

void
callCustomHandlers(Exception $exception, bool $fromConsole = false)

Handle the given exception.

void
displayException(Exception $exception)

Display the given exception to the user.

bool
handlesException(Closure $handler, Exception $exception)

Determine if the given handler handles this exception.

bool
hints(ReflectionFunction $reflection, Exception $exception)

Determine if the given handler type hints the exception.

string
formatException(Exception $e)

Format an exception thrown by a handler.

void
error(Closure $callback)

Register an application error handler.

void
pushError(Closure $callback)

Register an application error handler at the bottom of the stack.

prepareResponse(mixed $response)

Prepare the given response.

bool
runningInConsole()

Determine if we are running in the console.

void
setDebug(bool $debug)

Set the debug level for the handler.

Details

void __construct(ResponsePreparerInterface $responsePreparer, ExceptionDisplayerInterface $plainDisplayer, ExceptionDisplayerInterface $debugDisplayer, bool $debug = true)

Create a new error handler instance.

Parameters

ResponsePreparerInterface $responsePreparer
ExceptionDisplayerInterface $plainDisplayer
ExceptionDisplayerInterface $debugDisplayer
bool $debug

Return Value

void

void register(string $environment)

Register the exception / error handlers for the application.

Parameters

string $environment

Return Value

void

protected void registerErrorHandler()

Register the PHP error handler.

Return Value

void

protected void registerExceptionHandler()

Register the PHP exception handler.

Return Value

void

protected void registerShutdownHandler()

Register the PHP shutdown handler.

Return Value

void

handleError(int $level, string $message, string $file = '', int $line = 0, array $context = array())

Handle a PHP error for the application.

Parameters

int $level
string $message
string $file
int $line
array $context

Exceptions

ErrorException

Response handleException(Exception $exception)

Handle an exception for the application.

Parameters

Exception $exception

Return Value

Response

void handleUncaughtException(Exception $exception)

Handle an uncaught exception.

Parameters

Exception $exception

Return Value

void

void handleShutdown()

Handle the PHP shutdown event.

Return Value

void

protected bool isFatal(int $type)

Determine if the error type is fatal.

Parameters

int $type

Return Value

bool

void handleConsole(Exception $exception)

Handle a console exception.

Parameters

Exception $exception

Return Value

void

protected void callCustomHandlers(Exception $exception, bool $fromConsole = false)

Handle the given exception.

Parameters

Exception $exception
bool $fromConsole

Return Value

void

protected void displayException(Exception $exception)

Display the given exception to the user.

Parameters

Exception $exception

Return Value

void

protected bool handlesException(Closure $handler, Exception $exception)

Determine if the given handler handles this exception.

Parameters

Closure $handler
Exception $exception

Return Value

bool

protected bool hints(ReflectionFunction $reflection, Exception $exception)

Determine if the given handler type hints the exception.

Parameters

ReflectionFunction $reflection
Exception $exception

Return Value

bool

protected string formatException(Exception $e)

Format an exception thrown by a handler.

Parameters

Exception $e

Return Value

string

void error(Closure $callback)

Register an application error handler.

Parameters

Closure $callback

Return Value

void

void pushError(Closure $callback)

Register an application error handler at the bottom of the stack.

Parameters

Closure $callback

Return Value

void

protected Response prepareResponse(mixed $response)

Prepare the given response.

Parameters

mixed $response

Return Value

Response

bool runningInConsole()

Determine if we are running in the console.

Return Value

bool

void setDebug(bool $debug)

Set the debug level for the handler.

Parameters

bool $debug

Return Value

void