add error handler of rendering exceptions in brief

This commit is contained in:
printempw 2016-12-23 21:44:52 +08:00
parent 04de047b8a
commit 043dabaccf

View File

@ -72,17 +72,18 @@ class Handler extends ExceptionHandler
return $e->getResponse()->setStatusCode(200); return $e->getResponse()->setStatusCode(200);
} }
// render exceptions with whoops foreach ($this->dontReport as $type) {
if (config('app.debug')) { if ($e instanceof $type) {
foreach ($this->dontReport as $type) { return parent::render($request, $e);
if ($e instanceof $type) { } else {
return parent::render($request, $e); // hide exception details if not in debug mode
if (config('app.debug')) {
return $this->renderExceptionWithWhoops($e);
} else {
return $this->renderExceptionInBrief($e);
} }
} }
return $this->renderExceptionWithWhoops($e);
} }
return response()->view('errors.brief', ['code' => 0, 'message' => 'cmn']);
} }
/** /**
@ -104,4 +105,15 @@ class Handler extends ExceptionHandler
$e->getHeaders() $e->getHeaders()
); );
} }
/**
* Render an exception in a short word.
*
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
protected function renderExceptionInBrief(Exception $e)
{
return response()->view('errors.brief');
}
} }