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