- Drupal 基礎教程
- Drupal - 首頁
- Drupal - 概述
- Drupal - 安裝
- Drupal - 架構
- Drupal - 主選單
- Drupal - 塊與區域
- Drupal - 主題與佈局
- Drupal - 首頁
- Drupal - 靜態頁面
- Drupal - 建立部落格
- Drupal - 建立文章
- Drupal - 建立頁面
- Drupal - 建立內容
- Drupal - 修改內容
- Drupal - 刪除內容
- Drupal - 釋出內容
- Drupal - 選單管理
- Drupal - 分類法
- Drupal - 評論
- Drupal - 使用者管理
- Drupal - 最佳化
- Drupal - 站點備份
- Drupal - 站點升級
- Drupal - 公告
- Drupal 高階
- Drupal - URL 別名
- Drupal - 站點搜尋
- Drupal - 錯誤處理
- Drupal - 多語言內容
- Drupal - 觸發器與操作
- Drupal - 社交網路
- Drupal - 國際化
- Drupal - 擴充套件
- Drupal - 預設模組
- Drupal - 面板模組
- Drupal - 書籍模組
- Drupal - 聚合器模組
- Drupal - 聯絡模組
- Drupal - 表單模組
- Drupal - 投票模組
- Drupal - 站點安全
- Drupal 電子商務
- Drupal - 設定購物車
- Drupal - 建立產品
- Drupal - 建立類別
- Drupal - 設定稅費
- Drupal - 設定折扣
- Drupal - 接收捐贈
- Drupal - 設定運費
- Drupal - 設定支付
- Drupal - 發票生成
- Drupal - 郵件通知
- Drupal - 訂單歷史
- Drupal 有用資源
- Drupal - 問答
- Drupal - 快速指南
- Drupal - 有用資源
- Drupal - 討論
Drupal - 錯誤處理
在本章中,我們將學習關於 Drupal 錯誤處理,以管理 Drupal 站點上的錯誤訊息。
錯誤處理是一個檢測和查詢錯誤解決方案的過程。它可以是程式設計應用程式錯誤或可通訊錯誤。
以下步驟描述瞭如何在 Drupa 中管理錯誤訊息:
步驟 1 - 轉到配置並點選日誌和錯誤。
步驟 2 - 將顯示日誌和錯誤頁面,如下面的螢幕截圖所示。
以下是前面螢幕截圖中欄位的詳細資訊:
要顯示的錯誤訊息 - 它指定要在 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 請求中使用。此函式位於檔案includes/bootstrap.inc 的第 2328 行。
有兩個字串引用_drupal_exception_handler,例如_drupal_bootstrap_configuration() 存在於bootstrap.inc 檔案中,以及_drupal_get_last_caller 存在於 errors.inc 檔案中。這兩個檔案都位於“includes”資料夾中。
廣告
