Skip to content

woody-labs/middleware-exception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Middleware Exception

This middleware catch any exception thrown by deeper middleware.

For HttpException, a response with its code and message is created. For any other exception, an Internal Error is returned.

Implementation

Just add the middleware into your dispatcher pipeline at a nested level to catch any exception of deepest middleware.

// @todo: generate request

$dispatcher = new Dispatcher();
$dispatcher->pipe(new CorrelationIdMiddleware());
$dispatcher->pipe(new ExceptionMiddleware());
$dispatcher->pipe(new MyAddMiddleware());

// @todo: add other middleware

$response = $dispatcher->handle($request);

About

Middleware PSR-15 compliant which handle Exceptions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages