0
我通过Guzzle发送帖子,并且有些产品正在返回InvalidArgumentException错误,我如何获取此数据?不幸的是,在文档中没有关于这一点。如何使用Guzzle获取InvalidArgumentException?
这是错误
InvalidArgumentException in functions.php line 324:
json_encode error: Malformed UTF-8 characters, possibly incorrectly encoded
我的陷阱:
catch (ClientException $e) {
if ($e->hasResponse()) {
$resposta = Psr7\str($e->getResponse());
$incrementer->cron_value = $incrementer->cron_value + 1;
$incrementer->save();
return view('home');
}
}
catch (RequestException $e) {
return view('home');
if ($e->hasResponse()) {
$incrementer->cron_value = $incrementer->cron_value + 1;
$incrementer->save();
return view('home');
}
}
总是发送您的请求在尝试..catch块,例如try {//你的guzzle动作} catch(Exception $ e){echo $ e-> getMessage(); }' –
是的,我用try catch,但是我没有看到任何方法在Guzzle文档中得到这种错误。例如,我使用ClientException和RequestException,但由于错误是InvalidArgumentException,所以它不会通过try catch过滤 –
如果正确执行,则可以捕获所有异常。向我们展示你的'try' /'catch'。 – ceejayoz