Commit 70efe842 authored by Nicolas Widart's avatar Nicolas Widart

Adding default logic to handles 404s.

parent 7235efdf
...@@ -8,6 +8,7 @@ use Illuminate\Auth\Access\AuthorizationException; ...@@ -8,6 +8,7 @@ use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
...@@ -45,6 +46,21 @@ class Handler extends ExceptionHandler ...@@ -45,6 +46,21 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Exception $e) public function render($request, Exception $e)
{ {
if (config('app.debug') === false) {
return $this->handleExceptions($e);
}
return parent::render($request, $e); return parent::render($request, $e);
} }
private function handleExceptions($e)
{
if ($e instanceof ModelNotFoundException) {
return response()->view('errors.404', [], 404);
}
if ($e instanceof NotFoundHttpException) {
return response()->view('errors.404', [], 404);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment