From ca9cad7eeb1eec1782197877a6ca6d883dfcf448 Mon Sep 17 00:00:00 2001 From: Nathan Glenn Date: Wed, 14 Aug 2024 15:43:41 -0500 Subject: [PATCH] Improve `source` output * Though the exact error may be unknown, as far as the user is concerned "unknown error" is confusing; specify at the least that it is definitely a source error. * Put newlines in the proper locations so that the end of the stack trace and the beginning of the summary are not on the same line. --- Core/CLI/src/cli_CommandLineInterface.cpp | 2 ++ Core/CLI/src/cli_load_save.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Core/CLI/src/cli_CommandLineInterface.cpp b/Core/CLI/src/cli_CommandLineInterface.cpp index cf157d7cad..9dce9b8ac5 100644 --- a/Core/CLI/src/cli_CommandLineInterface.cpp +++ b/Core/CLI/src/cli_CommandLineInterface.cpp @@ -442,6 +442,7 @@ bool CommandLineInterface::SetError(const std::string& error) m_Result << std::endl; } m_Result << error; + m_Result << std::endl; m_LastError = error; return false; } @@ -454,6 +455,7 @@ bool CommandLineInterface::AppendError(const std::string& error) m_Result << std::endl; } m_Result << error; + m_Result << std::endl; m_LastError.append(error); return false; } diff --git a/Core/CLI/src/cli_load_save.cpp b/Core/CLI/src/cli_load_save.cpp index 3cd89a7b43..8700a48067 100644 --- a/Core/CLI/src/cli_load_save.cpp +++ b/Core/CLI/src/cli_load_save.cpp @@ -918,7 +918,7 @@ bool CommandLineInterface::Source(const char* buffer, bool printFileStack) if (printFileStack) { std::string temp; - sourceError.append("\n\t"); + sourceError.append("\t"); sourceError.append(m_SourceFileStack.top()); sourceError.append(":"); sourceError.append(to_string(line, temp)); @@ -927,10 +927,11 @@ bool CommandLineInterface::Source(const char* buffer, bool printFileStack) sourceError.append(":"); sourceError.append(to_string(line, temp)); } + sourceError.append("\n"); } if (sourceError.empty()) { // It's important that we don't return an empty error string, as that will be interpreted as success - sourceError = "Unknown error"; + sourceError = "Error while sourcing file"; } AppendError(sourceError); return false;