Skip to content

Conversation

WendellAdriel
Copy link
Contributor

Overview

I was talking with @christophrumpel on X and he showed me that calling a non-valid URL was not triggering the catch hook of the Http::batch

Http::batch(fn (Batch $batch) => [
    $batch->get('https://laravel.com'),
    $batch->get('https://laravell.comn'),
])->catch(function (Batch $batch, int|string $key, Response|RequestException $response) {
    dump('error');
})->send();

Fix

I saw that instead of a \Illuminate\Http\Client\RequestException in these cases it throws a \Illuminate\Http\Client\ConnectionException, so I added this check, and also updated the catch hook to handle this

Http::batch(fn (Batch $batch) => [
    $batch->get('https://laravel.com'),
    $batch->get('https://laravell.comn'),
])->catch(function (Batch $batch, int|string $key, Response|RequestException|ConnectionException $response) {
    dump('error');
})->send();

@taylorotwell taylorotwell merged commit 1b26183 into laravel:12.x Oct 14, 2025
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants