2011-12-17 32 views
1

我正在爲API擴展的形式開發MediaWiki 1.16擴展。我使用的數據庫訪問功能wfGetDB但我覺得很難甚至包括LocalSettings.php以下行調試,因爲不顯示完整的錯誤消息:顯示完整錯誤說明

error_reporting(E_ALL); 
ini_set('display_errors', 1); 
//... rest of the file ... 
$wgShowExceptionDetails = true; 

這裏是堆棧我得到的一個例子:

#0 /srv/www/htdocs/wotp/cd/includes/db/Database.php(538): DatabaseBase->reportQueryError('Unknown column ...', 1054, 'SELECT languag...', 'cdDictList::exe...', false) 
#1 /srv/www/htdocs/wotp/cd/includes/db/Database.php(874): DatabaseBase->query('SELECT languag...', 'cdDictList::exe...') 
#2 /srv/www/htdocs/wotp/cd/extensions/CommunityDictionary/includes/cdDictList.class.php(30): DatabaseBase->select('user_dictionary...', Array, Array, 'cdDictList::exe...', Array, Array) 
#3 /srv/www/htdocs/wotp/cd/includes/api/ApiMain.php(595): cdDictList->execute() 
#4 /srv/www/htdocs/wotp/cd/includes/api/ApiMain.php(338): ApiMain->executeAction() 
#5 /srv/www/htdocs/wotp/cd/includes/api/ApiMain.php(322): ApiMain->executeActionWithErrorHandling() 
#6 /srv/www/htdocs/wotp/cd/api.php(115): ApiMain->execute() 
#7 {main} 

有沒有辦法知道什麼是躲在背後...這樣我就可以知道哪個列例如未知?

回答

1

我自己找到答案。以下是捕獲異常,並顯示它的代碼:

try{ 
    $result = $this -> dbr -> select(...select code here...); 
} 
catch (Exception $e){ 
    error_log($e->getMessage()); 
    ApiBase :: dieDebug(__METHOD__, $e->getMessage()); 
} 

然後這個錯誤來自於這種形式:

<error code="internal_api_error_MWException" info="error text">