You can catch the issue at app/Exceptions/Handler.php
public function render($request, Throwable $e)
{
if ($e instanceof \Illuminate\Http\Exceptions\ThrottleRequestsException)
{
return here;
}
return parent::render($request, $e);
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
If someone , enter 01 invalid password. he will block in 01 minute , I want to customize "too many login attempts" error message, so i added these codes. it doesn't work
api.php
Route::group(['prefix' => 'user','middleware'=>['throttle:five_max_login_attempt_per_min']], function () {
........
});
try {
//Authentication
$isAuthenticatedUser = Auth::attempt(['email' => $loginRequest->input('email'), 'password' => $loginRequest->input('password')]);
if (!$isAuthenticatedUser) {
return SendResponseTrait::sendErrorWithToken('Invalid Email or Password', "Error", 401);
}
} catch (TooManyRequestsHttpException $tooManyRequestsHttpException) {
return SendResponseTrait::sendErrorWithToken('Too Many Login Attempts. Please wait 01 minute', "Error", 422);
Error Screen
"message": "Too Many Attempts.",
"exception": "Illuminate\Http\Exceptions\ThrottleRequestsException",
"file": "C:\wamp64\www\rmis\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php",
"line": 200,
"trace": [
{
"file": "C:\wamp64\www\rmis\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php",
"line": 121,
"function": "buildException",
"class": "Illuminate\Routing\Middleware\ThrottleRequests",
"type": "->"
},
You can catch the issue at app/Exceptions/Handler.php
public function render($request, Throwable $e)
{
if ($e instanceof \Illuminate\Http\Exceptions\ThrottleRequestsException)
{
return here;
}
return parent::render($request, $e);
}
Please or to participate in this conversation.