Drupal-error-handling

提供:Dev Guides
移動先:案内検索

Drupal-エラー処理

この章では、Drupalサイトでエラーメッセージを管理するためのDrupalエラー処理について学習します。

エラー処理は、エラーの検出と解決策を見つけるプロセスです。 プログラミングアプリケーションエラーまたは通信可能なエラーの可能性があります。

次の手順では、Drupaでエラーメッセージを管理する方法について説明します-

  • ステップ1 *-*構成*に移動し、*ログとエラー*をクリックします。

Drupalエラー処理

  • ステップ2 *-次の画面に示すように、*ログとエラー*ページが表示されます。

Drupalエラー処理

以下は、前の画面に表示されるフィールドの詳細です-

表示するエラーメッセージ-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行目にあります。

*bootstrap.inc* ファイルに存在する** _ drupal_bootstrap_configuration()**やerrors.incファイルに存在する* *_ drupal_get_last_caller* *など、 *_ drupal_exception_handler* への2つの文字列参照があります。 これらのファイルは両方とも *'includes'* フォルダーにあります。