Module: check_mk
Branch: master
Commit: ba01b616cc48a67f657193cf2cab816cf4032d35
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ba01b616cc48a6…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Nov 17 13:29:29 2017 +0100
Unified error messages a bit.
Change-Id: I0d0207853c4484f5dccbf70ffb62332e5b38c041
---
livestatus/src/Query.cc | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 4e7a6b9..3e2b50b 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -253,11 +253,14 @@ void Query::parseStatsAndOrLine(char *line, LogicalOperator op) {
auto number = nextNonNegativeIntegerArgument(&line);
// The last 'number' StatsColumns must be of type StatsOperation::count
std::vector<std::unique_ptr<Filter>> subfilters;
- for (; number > 0; --number) {
+ for (auto i = 0; i < number; ++i) {
if (_stats_columns.empty()) {
- throw std::runtime_error("too few Stats: headers available");
+ throw std::runtime_error(
+ "error combining filters for table '" + _table->name()
+
+ "': expected " + std::to_string(number) +
+ " filters, but only " + std::to_string(i) + " " +
+ (i == 1 ? "is" : "are") + " on stack");
}
-
auto &col = _stats_columns.back();
if (col->operation() != StatsOperation::count) {
throw std::runtime_error(
@@ -273,7 +276,8 @@ void Query::parseStatsAndOrLine(char *line, LogicalOperator op) {
void Query::parseStatsNegateLine(char *line) {
checkNoArguments(line);
if (_stats_columns.empty()) {
- throw std::runtime_error("no Stats: headers available");
+ throw("error combining filters for table '" + _table->name() +
+ "': expected 1 filters, but only 0 are on stack");
}
auto &col = _stats_columns.back();
if (col->operation() != StatsOperation::count) {