一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Laravel 5.1自定义500错误页面的例子

时间:2016-05-11 编辑:简简单单 来源:一聚教程网

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。

热门栏目