显示完整的错误描述

发布于 2024-12-21 17:20:26 字数 1220 浏览 1 评论 0原文

我正在以 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}

有没有办法知道 ... 后面隐藏了什么,以便我可以知道哪一列是未知的?

I am developing an extension for MediaWiki 1.16 in the form of an API extension. I'm using the database access function wfGetDB but I find it hard to debug because the full error messages are not displayed even by including the following lines in LocalSettings.php:

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

Here is an example of the stack I get:

#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}

Is there a way to know what is hiding behind the ... so I can know which column is unknown for example?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长梦不多时 2024-12-28 17:20:26

我自己找到了答案。下面是捕获异常并显示它的代码:

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">

I found the answer myself. Here is the code to catch the exception and display it:

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

The error then comes in this form:

<error code="internal_api_error_MWException" info="error text">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文