Optimize 404

This commit is contained in:
iVampireSP.com 2022-11-14 19:39:37 +08:00
parent 1da61c0f02
commit 74bbf6cadf
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -4,6 +4,8 @@
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\JsonResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;
class Handler extends ExceptionHandler
@ -45,7 +47,16 @@ class Handler extends ExceptionHandler
public function register()
{
$this->reportable(function (Throwable $e) {
//
// custom json 404 response
if ($e instanceof NotFoundHttpException) {
return response()->json([
'message' => 'Not Found',
'errors' => [
'code' => 404,
'message' => 'Not Found'
]
], 404);
}
});
}