Fixed #1043 (use cppcheck:.. syntax in error messages)

This commit is contained in:
Daniel Marjamäki 2009-12-05 08:08:28 +01:00
parent 052ce15176
commit 7f15fea735
2 changed files with 9 additions and 7 deletions

View File

@ -114,11 +114,11 @@ void CppCheck::parseFromArgs(int argc, const char* const argv[])
++i;
if (i >= argc)
throw std::runtime_error("No file specified for the --suppressions option");
throw std::runtime_error("cppcheck: No file specified for the --suppressions option");
std::ifstream f(argv[i]);
if (!f.is_open())
throw std::runtime_error("couldn't open the file \"" + std::string(argv[i]) + "\"");
throw std::runtime_error("cppcheck: Couldn't open the file \"" + std::string(argv[i]) + "\"");
_settings.suppressions(f);
}
@ -258,11 +258,11 @@ void CppCheck::parseFromArgs(int argc, const char* const argv[])
++i;
if (i >= argc || !strstr(argv[i], ".lst"))
throw std::runtime_error("No .lst file specified for the --auto-dealloc option");
throw std::runtime_error("cppcheck: No .lst file specified for the --auto-dealloc option");
std::ifstream f(argv[i]);
if (!f.is_open())
throw std::runtime_error("couldn't open the file \"" + std::string(argv[i+1]) + "\"");
throw std::runtime_error("cppcheck: couldn't open the file \"" + std::string(argv[i+1]) + "\"");
_settings.autoDealloc(f);
}

View File

@ -124,13 +124,13 @@ void Settings::addEnabled(const std::string &str)
while ((pos = str.find(",", pos)) != std::string::npos)
{
if (pos == prevPos)
throw std::runtime_error("wrong --enable argument ''");
throw std::runtime_error("cppcheck: --enable parameter is empty");
addEnabled(str.substr(prevPos, pos - prevPos));
++pos;
prevPos = pos;
}
if (prevPos >= str.length())
throw std::runtime_error("wrong --enable argument ''");
throw std::runtime_error("cppcheck: --enable parameter is empty");
addEnabled(str.substr(prevPos));
return;
}
@ -161,7 +161,9 @@ void Settings::addEnabled(const std::string &str)
}
else if (!handled)
{
throw std::runtime_error("wrong --enable argument '" + str + "'");
throw std::runtime_error(str.size() ?
std::string("cppcheck: there is no --enable parameter with the name '" + str + "'") :
std::string("cppcheck: --enable parameter is empty"));
}
}