【发布时间】:2020-07-15 02:30:23
【问题描述】:
如何从 Guzzle BadResponseException (ClientException || ServerException) 对象中检索使用的 form_params?
我在文档中找不到它。
try {
$reponse = $this->client->post($uri, [
'form_params' => $params,
'headers' => $this->getHeaders()
]);
} catch (RequestException $e){
/// get form_params here without accessing $params
}
【问题讨论】:
-
这能回答你的问题吗? Handle Guzzle exception and get HTTP body
-
RequestException是否等于Guzzle\Http\Exception\BadResponseException? Official documentation -
您发布的文档适用于 guzzle 3 docs.guzzlephp.org/en/stable/quickstart.html#exceptions。 RequestException 扩展了 BadResponseException
-
$response->getBody()->getContents() 的结果是什么?
-
响应正文有http错误。
标签: php exception guzzle6 guzzle