added import middleware

This commit is contained in:
Denis Duliçi
2021-12-03 15:43:15 +03:00
parent 3ec3e99216
commit b6ab9dd5e6
5 changed files with 36 additions and 15 deletions

View File

@ -5,6 +5,7 @@ namespace App\Exceptions;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Exceptions\ThrottleRequestsException;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;
@ -127,6 +128,13 @@ class Handler extends ExceptionHandler
return response()->view('errors.500', [], 500);
}
if ($exception instanceof ThrottleRequestsException) {
// ajax 500 json feedback
if ($request->ajax()) {
return response()->json(['error' => $exception->getMessage()], 429);
}
}
return parent::render($request, $exception);
}
}