bermudaphp/error-handler

v2.0.1 2023-03-11 20:32 UTC

This package is auto-updated.

Last update: 2024-11-12 00:20:22 UTC


README

composer require bermudaphp/error-handler

Usage

$generator = new ErrorResponseGenerator($psr17ResponseFactory, new WhoopsErrorGenerator($psr17ResponseFactory));
$generator->addGenerator($myConcreteErrorResponseGenerator);
$errorHandler = new ErrorHandlerMiddleware(new ErrorHandler($generator));
$pipeline->pipe($errorHandler); // Add ErrorHandlerMiddleware at the beginning of the middleware queue

Event listening

$errorListenerInterfaceInstance = new LogErrorListener($logger);
$errorHandler->on($errorListenerInterfaceInstance);

ServerErrorEvent

$request = $event->serverRequest;
$exception = $event->throwable;