public function render($request, Exception $e)
{
/* 错误页面 */
if ($e instanceof HttpException) {
$code = $e->getStatusCode();
if (view()->exists('errors.' . $code)) {
$message = $e->getMessage();
return response()->view('errors.' . $e->getStatusCode(), ['message'=>$message], $e->getStatusCode());
}
}
return parent::render($request, $e);
}
protected $dontReport = [
// AuthorizationException::class,
// HttpException::class,
// ModelNotFoundException::class,
// ValidationException::class,
];
public function render($request, Exception $e)
{
if (getenv('APP_DEBUG')) {
return parent::render($request, $e);
}else{
switch ($e){
case ($e instanceof HttpException):
//自定义处理异常,此处我们返回一个404页面
return view('errors.404');
break;
default:
//返回laravel默认的错误页面
return parent::render($request, $e);
}
}
}