Laravel 5.2 - 自定义错误“哎呀,好像出了点问题”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37498972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:52:58 来源:igfitidea点击:
Laravel 5.2 - customize error "Whoops, looks like something went wrong"
提问by user0111001101
How can I change the error page "Whoops, looks like something went wrong."? I want to show my page 404 inside errorsfolder my handler is simple:
如何更改错误页面“哎呀,好像出了点问题。”?我想在错误文件夹中显示我的页面 404我的处理程序很简单:
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
回答by IllegalPigeon
I assume you're already inside of app/Exceptions/Handler.php
我假设你已经在app/Exceptions/Handler.php 里面
public function render($request, Exception $e)
{
return response()->view('errors.custom');
}
回答by Achraf Khouadja
change that to
将其更改为
public function handle($request)
{
try
{
return parent::handle($request);
}
catch(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e)
{
return response()->view('Viewname', [], 404);
}
catch (Exception $e)
{
$this->reportException($e);
return $this->renderException($request, $e);
}
}