Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Added docs for 'throw' method #7876

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ If you would like to perform some additional logic before the exception is throw
//
})->json();

Alternatively, if you want to specify before the request is sent that you want to throw an instance of `Illuminate\Http\Client\RequestException` if the response status code indicates a client or server error on the request, you can use the `throw` method on the `PendingRequest` class:

// Throw an exception if a client or server error occurs...
$response = Http::throw()->post(...);

The `throw` method also accepts an optional closure that you can use to perform additional logic if the request encounters a client or server error:

return Http::throw(function ($response, $e) {
//
})->post(...);

<a name="guzzle-options"></a>
### Guzzle Options

Expand Down