跳转到主要内容
你行网

Main navigation

  • 首页
  • 文章
  • 教程
  • 视频
  • 下载
  • 社区
  • 网站导航
User account menu
  • 登录

面包屑

  1. 首页

3. Drupal 7 高级教程 - 错误处理

由 hrs, 13 八月, 2019
标签
drupal

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

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

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

步骤1 - 转到“ 配置”,然后单击“ 记录和错误”。

drupal-error-handling-step(1).jpg

步骤2 - 将显示“ 记录和错误”页面,如以下屏幕所示。

drupal-error-handling-step(2).jpg

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

  • 要显示的错误消息 - 它指定要在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 '<h1>Additional uncaught exception thrown while handling exception.</h1>';
         print '<h2>Original</h2> <p>'. _drupal_render_exception_safe($exception).'</p>';
         print '<h2>Additional</h2> <p>'. _drupal_render_exception_safe($excp2).'</p><hr/>';
      }
   }
}

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

有两个对_drupal_exception_handler的字符串引用,例如bootstrap.inc文件中存在_drupal_bootstrap_configuration(),errors.inc文件中存在_drupal_get_last_caller。这两个文件都存在于'includes'文件夹中。

评论

  • 登录或注册以发表评论

书籍遍历链接: 3. Drupal 7 高级教程 - 错误处理

  • 2. Drupal高级教程 - 网站搜索
  • 向上
  • 4. Drupal 7 高级教程- 多语言内容

相关文章

教程节点

  • 1. Drupal高级教程 - URL别名
  • 2. Drupal高级教程 - 网站搜索
  • 3. Drupal 7 高级教程 - 错误处理
  • 4. Drupal 7 高级教程- 多语言内容
  • 5. Drupal 高级教程- 触发器和动作
  • 6. Drupal 高级教程- 社交网络
  • 7. Drupal高级教程 - 国际化
  • 8. Drupal 高级教程- 扩展
  • 9. Drupal 高级教程 - 默认模块
  • 10. Drupal 高级教程- 窗格模块
  • 11. Drupal高级教程 - 书籍模块
  • 12. Drupal 高级教程- 聚合器模块
  • 13. Drupal 高级教程- 联系人模块
  • 14. Drupal 高级教程- 表单模块
  • 15. Drupal高级教程 - 民意调查模块
  • 16. Drupal 高级教程- 网站安全
RSS源
本站由阿里云强力驱动,幸运券优惠链接
Copyright © 2019 - 2021 你行网 版权所有  粤ICP备19072650号