From fc1464c6df5f0910e0bef585e03dcce60cdd0ba7 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 17 Aug 2020 12:50:24 -0700 Subject: [PATCH] Simplify error reporting (NFC) --- lldb/source/Target/Target.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index f014fe9..31016f7 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2942,26 +2942,20 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) { bool with_shell = !!launch_info.GetShell(); const int exit_status = m_process_sp->GetExitStatus(); const char *exit_desc = m_process_sp->GetExitDescription(); -#define LAUNCH_SHELL_MESSAGE \ - "\n'r' and 'run' are aliases that default to launching through a " \ - "shell.\nTry launching without going through a shell by using 'process " \ - "launch'." - if (exit_desc && exit_desc[0]) { - if (with_shell) - error.SetErrorStringWithFormat( - "process exited with status %i (%s)" LAUNCH_SHELL_MESSAGE, - exit_status, exit_desc); - else - error.SetErrorStringWithFormat("process exited with status %i (%s)", - exit_status, exit_desc); - } else { - if (with_shell) - error.SetErrorStringWithFormat( - "process exited with status %i" LAUNCH_SHELL_MESSAGE, exit_status); - else - error.SetErrorStringWithFormat("process exited with status %i", - exit_status); - } + std::string desc; + if (exit_desc && exit_desc[0]) + desc = " (" + std::string(exit_desc) + ')'; + if (with_shell) + error.SetErrorStringWithFormat( + "process exited with status %i%s\n" + "'r' and 'run' are aliases that default to launching through a " + "shell.\n" + "Try launching without going through a shell by using " + "'process launch'.", + exit_status, desc.c_str()); + else + error.SetErrorStringWithFormat("process exited with status %i%s", + exit_status, desc.c_str()); } break; default: error.SetErrorStringWithFormat("initial process state wasn't stopped: %s", -- 2.7.4