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