2
我正在使用\ lithium \ data \ source \ MongoDB :: update()在安全模式下執行upsert。在某些更新中,由於傳遞了重複鍵,因此會出現預期的MongoCursorException。下面的try/catch不會捕獲錯誤,並且它會回到我已經連接到Dispatcher :: run()的ErrorHandler。MongoCursorException被拋出,但沒有通過在鋰電池中的try/catch捕獲
try {
$result = Items::update($record, $conditions, array('upsert' => true, 'safe' => true));
} catch (MongoCursorException $e) {
$result = false;
} catch (Exception $e) {
$result = false;
}
Derp,我想我應該在嘗試自動完成時聽我的IDE。謝謝。 –
那個人也第一次來了我。 – rmarscher