Make error messages more user-friendly for the 'target delete' command.

llvm-svn: 159927
This commit is contained in:
Filipe Cabecinhas
2012-07-09 13:02:17 +00:00
parent 82dd00c5c3
commit f065fdcee7

View File

@@ -474,6 +474,13 @@ protected:
if (argc > 0)
{
const uint32_t num_targets = target_list.GetNumTargets();
// Bail out if don't have any targets.
if (num_targets == 0) {
result.AppendError("no targets to delete");
result.SetStatus(eReturnStatusFailed);
success = false;
}
for (uint32_t arg_idx = 0; success && arg_idx < argc; ++arg_idx)
{
const char *target_idx_arg = args.GetArgumentAtIndex(arg_idx);
@@ -489,9 +496,14 @@ protected:
continue;
}
}
result.AppendErrorWithFormat ("target index %u is out of range, valid target indexes are 0 - %u\n",
target_idx,
num_targets - 1);
if (num_targets > 1)
result.AppendErrorWithFormat ("target index %u is out of range, valid target indexes are 0 - %u\n",
target_idx,
num_targets - 1);
else
result.AppendErrorWithFormat("target index %u is out of range, the only valid index is 0\n",
target_idx);
result.SetStatus (eReturnStatusFailed);
success = false;
}