How to handle exceptions Guzzle?

Handle client errors and server errors so
try{

} catch (ClientException $e) {

} catch (ServerException $e) {

} catch (GuzzleException $e) {
}

How can I handle errors starting with 300?
March 19th 20 at 08:47
1 answer
March 19th 20 at 08:49
Error?
3** -- this is the server response codes (redirects), this is not an error
https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D...

4** and 5** - is the error (on the client and the server respectively)

Redirects are not for the exceptions
That is, redirects can be in any case? For example when you changed the url-respectively, then the exception is not the place you should work a mediator or a handler that the receipt of the request to the app-do a redirect.
@wilhelmine_Hoeger3 How am I suppose to catch the redirect virus? - lorena_Ankundi commented on March 19th 20 at 08:52
@lorena_Ankundi, and where it occurs? - wilhelmine_Hoeger3 commented on March 19th 20 at 08:55
@lorena_Ankundi,
you can disable auto-redirect

$client = new Client(['allow_redirects' => false]);
$response = $client->post('https://site.ru', ['form_params' => $formParams]);
$response->getHeaderLine('Location');
- devan23 commented on March 19th 20 at 08:58

Find more questions by tags PHP