Laravel 5.1 中如何自定义 500 错误页面

编辑PHP文件app/Exceptions/Handler.php内容如下:
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
if($e instanceof \Symfony\Component\Debug\Exception\FatalErrorException
&& !config('app.debug')) {
return response()->view('errors.default', [], 500);
}
return parent::render($request, $e);
}
然后编辑自定义错误页面对应视图文件errors.default.blade.php。
5 Comments