From 615e2a17e499b2bd53cce8da1a0cfae36d67b24a Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sat, 7 Jan 2017 13:48:44 +0100 Subject: cmCommand: Don't prefix error message with command name Instead, prefix the error message at the two places where the errors are handled: cmMakefile and cmCTestHandlerCommand. --- Source/CTest/cmCTestHandlerCommand.cxx | 4 ++-- Source/cmCommand.cxx | 7 ++----- Source/cmMakefile.cxx | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index a989b12..2a67d47 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -123,8 +123,8 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, if (capureCMakeError) { this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR], "-1"); - const char* err = this->GetError(); - if (err && !cmSystemTools::FindLastString(err, "unknown error.")) { + std::string const err = this->GetName() + " " + this->GetError(); + if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) { cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n"); } // return success because failure is recorded in CAPTURE_CMAKE_ERROR diff --git a/Source/cmCommand.cxx b/Source/cmCommand.cxx index 181b412..15bed27 100644 --- a/Source/cmCommand.cxx +++ b/Source/cmCommand.cxx @@ -23,17 +23,14 @@ bool cmCommand::InvokeInitialPass(const std::vector& args, const char* cmCommand::GetError() { if (this->Error.empty()) { - this->Error = this->GetName(); - this->Error += " unknown error."; + return "unknown error."; } return this->Error.c_str(); } void cmCommand::SetError(const std::string& e) { - this->Error = this->GetName(); - this->Error += " "; - this->Error += e; + this->Error = e; } bool cmCommand::Disallowed(cmPolicies::PolicyID pol, const char* e) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 618f694..bdaca97 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -281,7 +281,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, if (!invokeSucceeded || hadNestedError) { if (!hadNestedError) { // The command invocation requested that we report an error. - this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError()); + std::string const error = name + " " + pcmd->GetError(); + this->IssueMessage(cmake::FATAL_ERROR, error); } result = false; if (this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) { -- cgit v0.12