http_errors

Summary

Set to false to disable throwing exceptions on an HTTP protocol errors (i.e., 4xx and 5xx responses). Exceptions are thrown by default when HTTP protocol errors are encountered.

Types

bool

Default

true

Constant

GuzzleHttp\RequestOptions::HTTP_ERRORS

  1. $client->request('GET', '/status/500');
  2. // Throws a GuzzleHttp\Exception\ServerException
  3. $res = $client->request('GET', '/status/500', ['http_errors' => false]);
  4. echo $res->getStatusCode();
  5. // 500

Warning

This option only has an effect if your handler has the GuzzleHttp\Middleware::httpErrors middleware. This middleware is added by default when a client is created with no handler, and is added by default when creating a handler with GuzzleHttp\default_handler.