Skip to content

Commit b53c156

Browse files
JaZotaylorotwell
andauthored
[11.x] Document report method of ThrottlesExceptions middleware (#9557)
* Document `report` method of ThrottlesExceptions middleware * Update queues.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 2cda249 commit b53c156

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

queues.md

+17
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,23 @@ By default, this middleware will throttle every exception. You can modify this b
673673
)];
674674
}
675675

676+
If you would like to have the throttled exceptions reported to your application's exception handler, you can do so by invoking the `report` method when attaching the middleware to your job. Optionally, you may provide a closure to the `report` method and the exception will only be reported if the given closure returns `true`:
677+
678+
use Illuminate\Http\Client\HttpClientException;
679+
use Illuminate\Queue\Middleware\ThrottlesExceptions;
680+
681+
/**
682+
* Get the middleware the job should pass through.
683+
*
684+
* @return array<int, object>
685+
*/
686+
public function middleware(): array
687+
{
688+
return [(new ThrottlesExceptions(10, 10))->report(
689+
fn (Throwable $throwable) => $throwable instanceof HttpClientException
690+
)];
691+
}
692+
676693
> [!NOTE]
677694
> If you are using Redis, you may use the `Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis` middleware, which is fine-tuned for Redis and more efficient than the basic exception throttling middleware.
678695

0 commit comments

Comments
 (0)