Commit 17319f53 by Bagus Pambudi

error handling 404 to home page

parent 444a890c
...@@ -4,6 +4,7 @@ namespace App\Exceptions; ...@@ -4,6 +4,7 @@ namespace App\Exceptions;
use Exception; use Exception;
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
{ {
...@@ -46,6 +47,16 @@ class Handler extends ExceptionHandler ...@@ -46,6 +47,16 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)
{ {
// You can add your own exception here
// so redirect to the home route
if ($exception instanceof NotFoundHttpException) {
return redirect('/');
}
return parent::render($request, $exception); return parent::render($request, $exception);
} }
} }
...@@ -8306,5 +8306,5 @@ ...@@ -8306,5 +8306,5 @@
"php": "^7.1.3" "php": "^7.1.3"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.1.0" "plugin-api-version": "2.0.0"
} }
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