From 7f15fea735e71da8e509232b7e34e18a93022020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 5 Dec 2009 08:08:28 +0100 Subject: [PATCH] Fixed #1043 (use cppcheck:.. syntax in error messages) --- lib/cppcheck.cpp | 8 ++++---- lib/settings.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index b5eb2c29a..94187cff2 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -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); } diff --git a/lib/settings.cpp b/lib/settings.cpp index eb4e990f5..0343e8bef 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -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")); } }