开发手册 欢迎您!
软件开发者资料库

Drupal - 错误处理

Drupal错误处理 - 从简单和简单的步骤学习Drupal,从基本到高级概念,包括概述,安装,架构,主菜单,块和区域,主题和布局,首页,静态页面创建博客,创建文章,创建页面,创建内容,修改内容,删除内容,发布内容,多语言内容,URL别名,网站搜索,错误处理,菜单管理,分类,评论,用户管理,优化,网站备份,网站升级,公告,触发器和操作,社交网络,国际化,扩展,默认模块,窗格模块,书籍模块,聚合器模块,联系人模块,表单模块,轮询模块,站点安全,设置购物车,创建产品,创建类别,设置税,设置费用,设置折扣,接收捐赠,设置运输,设置付款,发票生成,电子邮件通知,订单历史记录。

在本章中,我们将研究Drupal错误处理以管理Drupal站点上的错误消息.

错误处理是一个检测和查找错误分辨率的过程.它可能是编程应用程序错误或可传播错误.

以下步骤描述了如何管理Drupa中的错误消息 :

步骤1 : 转到配置,然后单击记录和错误.

Drupal Error Handling

步骤2 : 将显示记录和错误页面,如下面的屏幕所示.

Drupal Error Handling

以下是前面屏幕中显示的字段的详细信息 :

  • 要显示的错误消息 : 它指定要在Drupal站点上显示的错误消息.

    •  : 去;此选项不显示任何错误消息.

    • 错误和警告 : 此选项仅显示与错误和警告相关的消息.

    • 所有消息 : 此选项指定要在网站上显示的所有类型的错误消息,例如错误,警告等.

  • 要保留的数据库日志消息 : 它表示要在数据库日志中保留的最大消息数.

Drupal使用 _drupal_exception_handler($ exception)处理网站错误的功能.这些错误不会包含在try/catch块中.当异常处理程序退出时,脚本不会执行该函数.

_drupal_exception_handler 的代码如下 :

function _drupal_exception_handler($exception) {   require_once DRUPAL_ROOT . '/includes/errors.inc';   try {      // display the error message in the log and return the error messages to the user      _drupal_log_error(_drupal_decode_exception($exception), TRUE);   }   catch (Exception $excp2) {      // Another uncaught exception was thrown while handling the first one.      // If we are displaying errors, then do so with no possibility of          a further uncaught exception being thrown.               if (error_displayable()) {         print '

Additional uncaught exception thrown while handling exception.

';         print '

Original

 

'. _drupal_render_exception_safe($exception).'

';         print '

Additional

 

'. _drupal_render_exception_safe($excp2).'


';      }   }}

每个Drupal请求都必须使用该函数.此函数出现在文件 includes/bootstrap.inc 中的第2328行.

有两个字符串引用 _drupal_exception_handler 等as _drupal_bootstrap_configuration()出现在 bootstrap.inc 文件中, _drupal_get_last_caller 出现在errors.inc文件中.这两个文件都存在于'includes'文件夹中.