示例#1
0
 protected function formatErrorBody($code, $message, $body, $backtrace = array(), $log = array())
 {
     $baseline = CorePlugin::getBaseline();
     if ($message === null) {
         if (isset(self::$messagecode[$code])) {
             $message = self::$messagecode[$code];
         } else {
             $message = "Error #{$code}";
         }
     }
     if (!DEBUG) {
         $body = "";
         $backtrace = array();
     }
     if (Template::findTemplate(ERROR_TEMPLATE) && !IS_CLI) {
         $tpt = new TemplateRes(array("code" => $code, "message" => $message, "body" => $body, "backtrace" => $backtrace, "baseline" => $baseline, "log" => $log));
         header("Content-type: text/html");
         $tpt->output(ERROR_TEMPLATE);
     }
     header("Content-type: text/plain");
     $body = "{$message} ({$code})\n{$body}";
     if (is_array($backtrace) && count($backtrace) > 0) {
         $body .= "\n\nBacktrace:\n";
         foreach ($backtrace as $n => $bt) {
             $body .= "#{$n}" . " {$bt[0]} ({$bt[1]}):\n" . (isset($bt[2]) ? $bt[2] . '->' : '') . (isset($bt[3]) ? $bt[3] . '(' . implode(', ', $bt[4]) . ')' : '') . "\n";
         }
     }
     $body .= "\n---\n" . $baseline . "\n";
     echo $body;
     Output::finish($code);
 }
示例#2
0
文件: Cli.class.php 项目: davbfr/cf
 public static function version()
 {
     self::enableHelp();
     self::pln(CorePlugin::getBaseline());
 }