How to handle exceptions Guzzle?

Handle client errors and server errors so

} 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
3** -- this is the server response codes (redirects), this is not an error

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
you can disable auto-redirect

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

Find more questions by tags PHP