Skip to content

[12.x] Http::batch - fix issue that non valid URL not triggering catch hook#57386

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
WendellAdriel:fix/http-batch-non-valid-url
Oct 14, 2025
Merged

[12.x] Http::batch - fix issue that non valid URL not triggering catch hook#57386
taylorotwell merged 1 commit into
laravel:12.xfrom
WendellAdriel:fix/http-batch-non-valid-url

Conversation

@WendellAdriel

Copy link
Copy Markdown
Member

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