Cleanup error output on expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@133834 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index 7d1af33..57dd7c7 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -335,7 +335,22 @@
}
else
{
- error_stream->PutCString(result_valobj_sp->GetError().AsCString());
+ const char *error_cstr = result_valobj_sp->GetError().AsCString();
+ if (error_cstr && error_cstr[0])
+ {
+ int error_cstr_len = strlen (error_cstr);
+ const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n';
+ if (strstr(error_cstr, "error:") != error_cstr)
+ error_stream->PutCString ("error: ");
+ error_stream->Write(error_cstr, error_cstr_len);
+ if (!ends_with_newline)
+ error_stream->EOL();
+ }
+ else
+ {
+ error_stream->PutCString ("error: unknown error\n");
+ }
+
if (result)
result->SetStatus (eReturnStatusFailed);
}