file(DOWNLOAD): Fix error message formatting

The SetError method automatically starts the message with the name of
the command.  Fix up calls to it so that we get "file DOWNLOAD..."
instead of "file FILE(DOWNLOAD ...".  Also reduce length of long lines
containing these calls.
This commit is contained in:
Brad King 2010-09-10 14:35:07 -04:00
parent f2b4a46677
commit 86025d3a38
1 changed files with 45 additions and 58 deletions

View File

@ -2571,8 +2571,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
std::vector<std::string>::const_iterator i = args.begin(); std::vector<std::string>::const_iterator i = args.begin();
if(args.size() < 3) if(args.size() < 3)
{ {
this->SetError("FILE(DOWNLOAD url file) must be called with " this->SetError("DOWNLOAD must be called with at least three arguments.");
"at least three arguments.");
return false; return false;
} }
++i; // Get rid of subcommand ++i; // Get rid of subcommand
@ -2598,8 +2597,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
} }
else else
{ {
this->SetError("FILE(DOWNLOAD url file TIMEOUT time) missing " this->SetError("DOWNLOAD missing time for TIMEOUT.");
"time for TIMEOUT.");
return false; return false;
} }
} }
@ -2608,8 +2606,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
++i; ++i;
if( i == args.end()) if( i == args.end())
{ {
this->SetError("FILE(DOWNLOAD url file LOG VAR) missing " this->SetError("DOWNLOAD missing VAR for LOG.");
"VAR for LOG.");
return false; return false;
} }
verboseLog = *i; verboseLog = *i;
@ -2619,8 +2616,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
++i; ++i;
if( i == args.end()) if( i == args.end())
{ {
this->SetError("FILE(DOWNLOAD url file STATUS VAR) missing " this->SetError("DOWNLOAD missing VAR for STATUS.");
"VAR for STATUS.");
return false; return false;
} }
statusVar = *i; statusVar = *i;
@ -2630,8 +2626,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
++i; ++i;
if( i == args.end()) if( i == args.end())
{ {
this->SetError("FILE(DOWNLOAD url file EXPECTED_MD5 sum) missing " this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
"sum value for EXPECTED_MD5.");
return false; return false;
} }
expectedMD5sum = cmSystemTools::LowerCase(*i); expectedMD5sum = cmSystemTools::LowerCase(*i);
@ -2654,8 +2649,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
if (!cmSystemTools::ComputeFileMD5(file.c_str(), computedMD5)) if (!cmSystemTools::ComputeFileMD5(file.c_str(), computedMD5))
{ {
this->SetError("FILE(DOWNLOAD ) error; cannot compute MD5 sum on " this->SetError("DOWNLOAD cannot compute MD5 sum on pre-existing file");
"pre-existing file");
return false; return false;
} }
@ -2665,7 +2659,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
if (expectedMD5sum == actualMD5sum) if (expectedMD5sum == actualMD5sum)
{ {
this->Makefile->DisplayStatus( this->Makefile->DisplayStatus(
"FILE(DOWNLOAD ) returning early: file already exists with " "FILE(DOWNLOAD) returning early: file already exists with "
"expected MD5 sum", -1); "expected MD5 sum", -1);
if(statusVar.size()) if(statusVar.size())
@ -2698,8 +2692,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
std::ofstream fout(file.c_str(), std::ios::binary); std::ofstream fout(file.c_str(), std::ios::binary);
if(!fout) if(!fout)
{ {
this->SetError("FILE(DOWNLOAD url file TIMEOUT time) can not open " this->SetError("DOWNLOAD cannot open file for write.");
"file for write.");
return false; return false;
} }
@ -2708,8 +2701,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
curl = ::curl_easy_init(); curl = ::curl_easy_init();
if(!curl) if(!curl)
{ {
this->SetError("FILE(DOWNLOAD ) error " this->SetError("DOWNLOAD error initializing curl.");
"initializing curl.");
return false; return false;
} }
@ -2718,9 +2710,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set url: "; std::string e = "DOWNLOAD cannot set url: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
@ -2728,10 +2720,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
cmFileCommandWriteMemoryCallback); cmFileCommandWriteMemoryCallback);
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = std::string e = "DOWNLOAD cannot set write function: ";
"FILE(DOWNLOAD ) error; cannot set write function: "; e += ::curl_easy_strerror(res);
errstring += ::curl_easy_strerror(res); this->SetError(e.c_str());
this->SetError(errstring.c_str());
return false; return false;
} }
@ -2739,10 +2730,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
cmFileCommandCurlDebugCallback); cmFileCommandCurlDebugCallback);
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = std::string e = "DOWNLOAD cannot set debug function: ";
"FILE(DOWNLOAD ) error; cannot set debug function: "; e += ::curl_easy_strerror(res);
errstring += ::curl_easy_strerror(res); this->SetError(e.c_str());
this->SetError(errstring.c_str());
return false; return false;
} }
@ -2752,27 +2742,27 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set write data: "; std::string e = "DOWNLOAD cannot set write data: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set debug data: "; std::string e = "DOWNLOAD cannot set debug data: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set follow-redirect option: "; std::string e = "DOWNLOAD cannot set follow-redirect option: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
@ -2782,9 +2772,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set verbose: "; std::string e = "DOWNLOAD cannot set verbose: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
} }
@ -2795,9 +2785,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set timeout: "; std::string e = "DOWNLOAD cannot set timeout: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
} }
@ -2815,9 +2805,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
CURLOPT_NOPROGRESS, 0); CURLOPT_NOPROGRESS, 0);
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set noprogress value: "; std::string e = "DOWNLOAD cannot set noprogress value: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
@ -2825,9 +2815,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
CURLOPT_PROGRESSFUNCTION, cmFileCommandCurlProgressCallback); CURLOPT_PROGRESSFUNCTION, cmFileCommandCurlProgressCallback);
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set progress function: "; std::string e = "DOWNLOAD cannot set progress function: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
@ -2835,9 +2825,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
CURLOPT_PROGRESSDATA, reinterpret_cast<void*>(&helper)); CURLOPT_PROGRESSDATA, reinterpret_cast<void*>(&helper));
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
std::string errstring = "FILE(DOWNLOAD ) error; cannot set progress data: "; std::string e = "DOWNLOAD cannot set progress data: ";
errstring += ::curl_easy_strerror(res); e += ::curl_easy_strerror(res);
this->SetError(errstring.c_str()); this->SetError(e.c_str());
return false; return false;
} }
} }
@ -2871,8 +2861,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
if (!cmSystemTools::ComputeFileMD5(file.c_str(), computedMD5)) if (!cmSystemTools::ComputeFileMD5(file.c_str(), computedMD5))
{ {
this->SetError("FILE(DOWNLOAD ) error; cannot compute MD5 sum on " this->SetError("DOWNLOAD cannot compute MD5 sum on downloaded file");
"downloaded file");
return false; return false;
} }
@ -2882,8 +2871,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
if (expectedMD5sum != actualMD5sum) if (expectedMD5sum != actualMD5sum)
{ {
cmOStringStream oss; cmOStringStream oss;
oss << "FILE(DOWNLOAD ) error; expected and actual MD5 sums differ" oss << "DOWNLOAD MD5 mismatch" << std::endl
<< std::endl
<< " for file: [" << file << "]" << std::endl << " for file: [" << file << "]" << std::endl
<< " expected MD5 sum: [" << expectedMD5sum << "]" << std::endl << " expected MD5 sum: [" << expectedMD5sum << "]" << std::endl
<< " actual MD5 sum: [" << actualMD5sum << "]" << std::endl << " actual MD5 sum: [" << actualMD5sum << "]" << std::endl
@ -2913,8 +2901,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string>
return true; return true;
#else #else
this->SetError("FILE(DOWNLOAD ) " this->SetError("DOWNLOAD not supported by bootstrap cmake.");
"not supported in bootstrap cmake ");
return false; return false;
#endif #endif
} }