在PHP-on-couch中尝试/捕获块而不是捕获异常

时间:2013-04-10 06:50:45

标签: php couchdb

我有以下PHP代码:

try{
$doc = couchDocument::getInstance($db,"document10");
}catch(couchExpention $e){
    echo $e->getMessage();
}

然而,我得到的不是所需的输出:

PHP Fatal error:  Uncaught exception 'couchNotFoundException' with message 'Object Not Found - missing (GET /db/document10[])' in /var/www/public_html/lib/couchClient.php:1012
Stack trace:
#0 /var/www/public_html/lib/couchClient.php(157): couchException::factory(Array, 'GET', '/db/169488e77e2...', Array)
#1 /var/www/public_html/lib/couchClient.php(427): couchClient->_queryAndTest('GET', '/db/169488e77e2...', Array, Array)
#2 /var/www/public_html/lib/couchDocument.php(47): couchClient->getDoc('169488e77e2j385...')
#3 /var/www/public_html/lib/couchDocument.php(102): couchDocument->load('169488e77e2j385...')
#4 /var/www/public_html/index.php(8): couchDocument::getInstance(Object(couchClient), '169488e77e2j385...')
#5 {main}
  thrown in /var/www/public_html/lib/couchClient.php on line 1012

1 个答案:

答案 0 :(得分:0)

您的代码正试图抓住couchExpention而不是couchException