我想为一个Laravel5
包编写一个单独的exception handler
,以便它显示该包的自定义404
视图
实际上,我想知道如何在包的提供程序中注册包的Exception Handler
。
例如,如果我的包的名称是testPackage
,则我的ExceptionHandler
文件位于:
vendor/testPackage/src/Exceptions/testExceptionHandler.php
404
视图文件位于:
vendor/testPackage/src/views/404.blade.php
public function render($request, Exception $e)
{
if($e instanceof NotFoundHttpException)
{
return response()->view('missing', [], 404);
}
return parent::render($request, $e);
}
在testExceptionHandler.php 中添加此代码