Skip to content

Commit ca83fab

Browse files
committed
unifying exception message: review
1 parent fc35191 commit ca83fab

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/base/style/sheet.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ template <class Params> class Sheet
7171
{
7272
if (!hasParam(path))
7373
throw std::logic_error(
74-
"non-existent style parameter: " + std::string(path));
74+
path + "/" + value
75+
+ ": non-existent style parameter");
7576

7677
Style::ParamRegistry<Params>::instance().visit(path,
7778
[&](auto &p)
@@ -104,20 +105,20 @@ template <class Params> class Sheet
104105

105106
if (count == 0)
106107
throw std::logic_error(
107-
"non-existent style parameter(s): "
108-
+ std::string(path) + ".*");
108+
path + ".*: non-existent style parameter(s)");
109109
}
110110
else
111111
throw std::logic_error(
112-
"non-existent style parameter: " + std::string(path));
112+
path + "/" + value
113+
+ ": non-existent style parameter");
113114
}
114115

115116
static std::string getParam(Params &params,
116117
const std::string &path)
117118
{
118119
if (!hasParam(path))
119120
throw std::logic_error(
120-
"non-existent style parameter: " + std::string(path));
121+
path + ": non-existent style parameter");
121122

122123
std::string res;
123124
Style::ParamRegistry<Params>::instance().visit(path,

src/chart/options/config.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ void Config::setParam(const std::string &path,
3535
auto it = accessors.find(path);
3636
if (it == accessors.end())
3737
throw std::logic_error(
38-
std::string(path) + "/" + value
39-
+ ": invalid config parameter: " + path);
38+
path + "/" + value + ": invalid config parameter");
4039
it->second.set(*setter, value);
4140
}
4241
}
@@ -50,7 +49,7 @@ std::string Config::getParam(const std::string &path) const
5049
auto it = accessors.find(path);
5150
if (it == accessors.end())
5251
throw std::logic_error(
53-
"invalid config parameter: " + path);
52+
path + ": invalid config parameter");
5453
return it->second.get(setter->getOptions());
5554
}
5655
}
@@ -119,15 +118,15 @@ void Config::setChannelParam(const std::string &path,
119118
Conv::parse<OptionalChannelExtrema>(value));
120119
}
121120
else
122-
throw std::logic_error(std::string(path) + "/" + value
123-
+ ": invalid range setting");
121+
throw std::logic_error(
122+
path + "/" + value + ": invalid range setting");
124123
}
125124
else if (property == "labelLevel") {
126125
setter->setLabelLevel(id, Conv::parse<uint64_t>(value));
127126
}
128127
else
129128
throw std::logic_error(
130-
std::string(path) + "/" + value
129+
path + "/" + value
131130
+ ": invalid channel parameter: " + property);
132131
}
133132

@@ -176,14 +175,13 @@ std::string Config::getChannelParam(const std::string &path) const
176175
}
177176
else
178177
throw std::logic_error(
179-
"invalid range parameter: " + path);
178+
path + ": invalid range parameter");
180179
}
181180
else if (property == "labelLevel") {
182181
return Conv::toString(channel.labelLevel);
183182
}
184183
else
185-
throw std::logic_error(
186-
"invalid channel parameter: " + property);
184+
throw std::logic_error(path + ": invalid channel parameter");
187185
}
188186

189187
std::list<std::string> Config::listChannelParams()

0 commit comments

Comments
 (0)