http_errors

摘要

设置成 false 来禁用HTTP协议抛出的异常(如 4xx 和 5xx 响应),默认情况下HTPP协议出错时会抛出异常。

类型

bool

默认值

true

常量

GuzzleHttp\RequestOptions::HTTP_ERRORS

1. $client->request('GET', '/status/500');
2. // Throws a GuzzleHttp\Exception\ServerException

4. $res = $client->request('GET', '/status/500', ['http_errors' => false]);
5. echo $res->getStatusCode();
6. // 500