CustomExceptionHandler.php000064400000002165150247564410011720 0ustar00getUrl()->contains('/api')) { response()->json([ 'error' => $error->getMessage(), 'code' => $error->getCode(), ]); } /* The router will throw the NotFoundHttpException on 404 */ if($error instanceof NotFoundHttpException) { /* * Render your own custom 404-view, rewrite the request to another route, * or simply return the $request object to ignore the error and continue on rendering the route. * * The code below will make the router render our page.notfound route. */ $request->setRewriteCallback('DefaultController@notFound'); return; } throw $error; } }