original_string: public static function early_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = null) {
          global $CFG;
  
          if (CLI_SCRIPT) {
              echo "!!! $message !!!\n";
              if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) {
                  if (!empty($debuginfo)) {
                      echo "\nDebug info: $debuginfo";
                  }
                  if (!empty($backtrace)) {
                      echo "\nStack trace: " . format_backtrace($backtrace, true);
                  }
              }
              return;
  
          } else if (AJAX_SCRIPT) {
              $e = new stdClass();
              $e->error      = $message;
              $e->stacktrace = NULL;
              $e->debuginfo  = NULL;
              if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) {
                  if (!empty($debuginfo)) {
                      $e->debuginfo = $debuginfo;
                  }
                  if (!empty($backtrace)) {
                      $e->stacktrace = format_backtrace($backtrace, true);
                  }
              }
              $e->errorcode  = $errorcode;
              @header('Content-Type: application/json; charset=utf-8');
              echo json_encode($e);
              return;
          }
  
          // In the name of protocol correctness, monitoring and performance
          // profiling, set the appropriate error headers for machine consumption.
          $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
          @header($protocol . ' 503 Service Unavailable');
  
          // better disable any caching
          @header('Content-Type: text/html; charset=utf-8');
          @header('X-UA-Compatible: IE=edge');
          @header('Cache-Control: no-store, no-cache, must-revalidate');
          @header('Cache-Control: post-check=0, pre-check=0', false);
          @header('Pragma: no-cache');
          @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
          @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  
          if (function_exists('get_string')) {
              $strerror = get_string('error');
          } else {
              $strerror = 'Error';
          }
  
          $content = self::early_error_content($message, $moreinfourl, $link, $backtrace, $debuginfo);
  
          return self::plain_page($strerror, $content);
      }
code: public static function early_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = null) {
          global $CFG;
  
          if (CLI_SCRIPT) {
              echo "!!! $message !!!\n";
              if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) {
                  if (!empty($debuginfo)) {
                      echo "\nDebug info: $debuginfo";
                  }
                  if (!empty($backtrace)) {
                      echo "\nStack trace: " . format_backtrace($backtrace, true);
                  }
              }
              return;
  
          } else if (AJAX_SCRIPT) {
              $e = new stdClass();
              $e->error      = $message;
              $e->stacktrace = NULL;
              $e->debuginfo  = NULL;
              if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) {
                  if (!empty($debuginfo)) {
                      $e->debuginfo = $debuginfo;
                  }
                  if (!empty($backtrace)) {
                      $e->stacktrace = format_backtrace($backtrace, true);
                  }
              }
              $e->errorcode  = $errorcode;
              @header('Content-Type: application/json; charset=utf-8');
              echo json_encode($e);
              return;
          }
  
          // In the name of protocol correctness, monitoring and performance
          // profiling, set the appropriate error headers for machine consumption.
          $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
          @header($protocol . ' 503 Service Unavailable');
  
          // better disable any caching
          @header('Content-Type: text/html; charset=utf-8');
          @header('X-UA-Compatible: IE=edge');
          @header('Cache-Control: no-store, no-cache, must-revalidate');
          @header('Cache-Control: post-check=0, pre-check=0', false);
          @header('Pragma: no-cache');
          @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
          @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  
          if (function_exists('get_string')) {
              $strerror = get_string('error');
          } else {
              $strerror = 'Error';
          }
  
          $content = self::early_error_content($message, $moreinfourl, $link, $backtrace, $debuginfo);
  
          return self::plain_page($strerror, $content);
      }
code_tokens: public static function early_error ( $ message , $ moreinfourl , $ link , $ backtrace , $ debuginfo = null , $ errorcode = null ) { global $ CFG ; if ( CLI_SCRIPT ) { echo "!!! $message !!!\n" ; if ( ! empty ( $ CFG -> debug ) and $ CFG -> debug >= DEBUG_DEVELOPER ) { if ( ! empty ( $ debuginfo ) ) { echo "\nDebug info: $debuginfo" ; } if ( ! empty ( $ backtrace ) ) { echo "\nStack trace: " . format_backtrace ( $ backtrace , true ) ; } } return ; } else if ( AJAX_SCRIPT ) { $ e = new stdClass ( ) ; $ e -> error = $ message ; $ e -> stacktrace = NULL ; $ e -> debuginfo = NULL ; if ( ! empty ( $ CFG -> debug ) and $ CFG -> debug >= DEBUG_DEVELOPER ) { if ( ! empty ( $ debuginfo ) ) { $ e -> debuginfo = $ debuginfo ; } if ( ! empty ( $ backtrace ) ) { $ e -> stacktrace = format_backtrace ( $ backtrace , true ) ; } } $ e -> errorcode = $ errorcode ; @ header ( 'Content-Type: application/json; charset=utf-8' ) ; echo json_encode ( $ e ) ; return ; } // In the name of protocol correctness, monitoring and performance // profiling, set the appropriate error headers for machine consumption. $ protocol = ( isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ? $ _SERVER [ 'SERVER_PROTOCOL' ] : 'HTTP/1.0' ) ; @ header ( $ protocol . ' 503 Service Unavailable' ) ; // better disable any caching @ header ( 'Content-Type: text/html; charset=utf-8' ) ; @ header ( 'X-UA-Compatible: IE=edge' ) ; @ header ( 'Cache-Control: no-store, no-cache, must-revalidate' ) ; @ header ( 'Cache-Control: post-check=0, pre-check=0' , false ) ; @ header ( 'Pragma: no-cache' ) ; @ header ( 'Expires: Mon, 20 Aug 1969 09:23:00 GMT' ) ; @ header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ) ; if ( function_exists ( 'get_string' ) ) { $ strerror = get_string ( 'error' ) ; } else { $ strerror = 'Error' ; } $ content = self :: early_error_content ( $ message , $ moreinfourl , $ link , $ backtrace , $ debuginfo ) ; return self :: plain_page ( $ strerror , $ content ) ; }
docstring: This function should only be called by this class, or from exception handlers
  @static
  @param string $message error message
  @param string $moreinfourl (ignored in early errors)
  @param string $link (ignored in early errors)
  @param array $backtrace
  @param string $debuginfo extra information for developers
  @return string
docstring_tokens: This function should only be called by this class or from exception handlers