charm / exception-middleware
提供PSR-15中间件,用于捕获异常并渲染一个友好的错误页面。
1.0.0
2022-03-04 12:06 UTC
Requires
- charm/interop: ^0.0.1
README
这是一个简单的中间件实现,它捕获异常堆栈中后续抛出的异常,并渲染一个友好的错误信息。
配置
$middleware = new ExceptionMiddleware([
'error_handler' => function(\Throwable $e) {
if ($e->getCode() === 404) {
return render_page_not_found();
}
// If error handler returns null, the ExceptionMiddleware will render a response.
return null;
}
]);