[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

Vy Nguyen via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 11 08:10:49 PDT 2024


================
@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char *args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
     error_msg.assign("ambiguous command ");
-  else
-    error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+    error_msg.append("'");
+    error_msg.append(std::string(GetCommandName()));
+    error_msg.append(" ");
+    error_msg.append(std::string(sub_command));
+    error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
     error_msg.append(" Possible completions:");
     for (const std::string &match : matches) {
       error_msg.append("\n\t");
       error_msg.append(match);
     }
+  } else {
+    // Rather than simply complaining about the invalid (sub) command,
+    // try to offer some alternatives.
----------------
oontvoo wrote:

done

https://github.com/llvm/llvm-project/pull/111891


More information about the lldb-commits mailing list