feat(php): 添加错误时打印回溯跟踪的配置选项

- 在 CompilerBase 类中新增 printBacktraceOnError 属性,默认值为 false
- 修改错误处理逻辑,仅在 printBacktraceOnError 为 true 时调用 debug_print_backtrace()
- 保持原有错误消息显示和程序退出功能不变
pull/1/head
韩天峰 4 months ago
parent e5b7955fa1
commit 45a4582d03
  1. 5
      src/Php/CompilerBase.php

@ -164,6 +164,7 @@ class CompilerBase extends \PhpAot\Core\Translator
protected string $ldflags = '';
protected int $floatPrecision = 17;
protected bool $debugInfo = true;
protected bool $printBacktraceOnError = false;
protected bool $noLiteralStrings = false;
protected string $file;
protected string $dir;
@ -2237,7 +2238,9 @@ class CompilerBase extends \PhpAot\Core\Translator
throw new TestError($msg);
} else {
$this->climate->red("Fatal error: {$msg}");
debug_print_backtrace();
if ($this->printBacktraceOnError) {
debug_print_backtrace();
}
exit(255);
}
}

Loading…
Cancel
Save