Skip to content

[12.x] Add Http::requestException()#55241

Merged
taylorotwell merged 3 commits into
laravel:12.xfrom
cosmastech:request-exception-helper
Apr 2, 2025
Merged

[12.x] Add Http::requestException()#55241
taylorotwell merged 3 commits into
laravel:12.xfrom
cosmastech:request-exception-helper

Conversation

@cosmastech

@cosmastech cosmastech commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

I had a need earlier to throw a RequestException for an exception throwing stub class.

It wasn't super obvious how to do it; I ended up with something like:

Before

$exception = new RequestException(
    new Response(
        Http::response(['code' => 'not_found', 404)->wait()
    )
);

While this is fine, I thought maybe a helper (to go along with the failedConnection() method) would be appreciated by others.

After

$exception = Http::requestException(['code' => 'not_found'], 404);

@github-actions

github-actions Bot commented Apr 1, 2025

Copy link
Copy Markdown

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@cosmastech cosmastech marked this pull request as ready for review April 1, 2025 23:48
@taylorotwell taylorotwell merged commit 0a48401 into laravel:12.x Apr 2, 2025
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