1
我相信Cloudant最近更改了他們的一些代碼。最近,如果您在try/catch語句中執行了一個storedoc操作。 Cloudant會返回一個「錯誤」的框架:Cloudant和Php-on-Couch由於繼續而不能正常工作
未捕獲的異常「couchException」有消息「繼續
當然,你可以處理它在catch語句,但它確實應該回來的」成功「在PHP-on-Couch庫的Try語句中。
任何人都會遇到這個問題或知道如何處理它?最大的問題是,因爲它的未來作爲一個錯誤,你不能搶在catch語句的ID和Rev:
try { // does not return here, goes to catch
$response = $client->storeDoc($doc);
$response_json['status'] = 'success';
$response_json['id'] = $response->id;
$response_json['rev'] = $response->rev;
} catch (Exception $e) { // even though the doc is successfully storing
// check for accepted BEG
$error = '';
$error = $e->getMessage();
$err_pos = strpos($error,"Accepted");
$err_pos_2 = strpos($error,"Continue");
if($err_pos !== false OR $err_pos_2 !== false){ // success
$response_json['status'] = 'success';
$response_json['id'] = $response->id; // returns null
$response_json['rev'] = $response->rev; // returns null
} else { // truely an error
$response_json['status'] = 'fail';
$response_json['message'] = $e->getMessage();
$response_json['code'] = $e->getCode();
}
// check for accepted END
}
我試過了bot h方式,帶'message setAutocommit不存在'的未捕獲異常'異常'和類似的$ doc-> set一切工作正常可能幾個星期到一個月前左右。 – Matt
這是你正在使用的庫嗎? https://github.com/dready92/PHP-on-Couch。我剛剛下載了PHP文件,當我回答這個問題時,他們爲我工作。 – markwatsonatx
啊原諒我...我需要使用'couch_document class'...將在稍後測試。感謝您的快速回復和解決方案。 – Matt