浏览代码

refactor & feat: 调整错误回溯的输出顺序

SongZihuan 3 年之前
父节点
当前提交
657d750fc2
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/core/msg.cpp

+ 4 - 4
src/core/msg.cpp

@@ -27,13 +27,13 @@ void ErrorMessage::topProgress(){
     inter->getEnvVarSpace()->findNumber("sys:error_std", error_std);
     if (error_std == 0) {
         printf_stderr(0, "Error TrackBack\n");
-        for (auto begin = trackback.rbegin(), end = trackback.rend(); begin != end; begin++)
-            printf_stderr(0, "  File \"%s\", line %d\n", begin->path.c_str(), begin->line);
+        for (auto & begin : trackback)
+            printf_stderr(0, "  File \"%s\", line %d\n", begin.path.c_str(), begin.line);
         printf_stderr(0, "%s: %s\n", error_type.c_str(), error_info.c_str());
     } else {
         printf_stdout(0, "Error TrackBack\n");
-        for (auto begin = trackback.rbegin(), end = trackback.rend(); begin != end; begin++)
-            printf_stdout(0, "  File \"%s\", line %d\n", begin->path.c_str(), begin->line);
+        for (auto & begin : trackback)
+            printf_stdout(0, "  File \"%s\", line %d\n", begin.path.c_str(), begin.line);
         printf_stdout(0, "%s: %s\n", error_type.c_str(), error_info.c_str());
     }
 }