Skip to content

Commit fc35191

Browse files
committed
fix exception messages + reformat config.cpp
1 parent b1ed5ed commit fc35191

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/apps/weblib/interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void Interface::setChartValue(const char *path, const char *value)
109109
if (chart)
110110
chart->getConfig().setParam(path, value);
111111
else
112-
throw std::logic_error(std::string(path) + "/" + value + ": " + "No chart exists");
112+
throw std::logic_error("No chart exists");
113113
}
114114

115115
void Interface::relToCanvasCoords(double rx,

src/chart/options/config.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ void Config::setParam(const std::string &path,
3535
auto it = accessors.find(path);
3636
if (it == accessors.end())
3737
throw std::logic_error(
38-
"invalid config parameter: " + path);
38+
std::string(path) + "/" + value
39+
+ ": invalid config parameter: " + path);
3940
it->second.set(*setter, value);
4041
}
4142
}
@@ -118,14 +119,16 @@ void Config::setChannelParam(const std::string &path,
118119
Conv::parse<OptionalChannelExtrema>(value));
119120
}
120121
else
121-
throw std::logic_error("invalid range setting");
122+
throw std::logic_error(std::string(path) + "/" + value
123+
+ ": invalid range setting");
122124
}
123125
else if (property == "labelLevel") {
124126
setter->setLabelLevel(id, Conv::parse<uint64_t>(value));
125127
}
126128
else
127129
throw std::logic_error(
128-
"invalid channel parameter: " + property);
130+
std::string(path) + "/" + value
131+
+ ": invalid channel parameter: " + property);
129132
}
130133

131134
std::string Config::getChannelParam(const std::string &path) const
@@ -136,9 +139,7 @@ std::string Config::getChannelParam(const std::string &path) const
136139

137140
auto &channel = setter->getOptions().getChannels().at(id);
138141

139-
if (property == "title") {
140-
return Conv::toString(channel.title);
141-
}
142+
if (property == "title") { return Conv::toString(channel.title); }
142143
else if (property == "axis") {
143144
return Conv::toString(channel.axisLine);
144145
}
@@ -236,7 +237,7 @@ Config::Accessors Config::initAccessors()
236237
[](const Options &options)
237238
{
238239
auto cs{options.polar ? CoordSystem::polar
239-
: CoordSystem::cartesian};
240+
: CoordSystem::cartesian};
240241
return Conv::toString(cs);
241242
},
242243
.set =
@@ -263,8 +264,7 @@ Config::Accessors Config::initAccessors()
263264
{.get =
264265
[](const Options &options)
265266
{
266-
return Conv::toString(
267-
options.shapeType);
267+
return Conv::toString(options.shapeType);
268268
},
269269
.set =
270270
[](OptionsSetter &setter, const std::string &value)
@@ -276,9 +276,8 @@ Config::Accessors Config::initAccessors()
276276
{.get =
277277
[](const Options &options)
278278
{
279-
auto res(options.horizontal
280-
? Orientation::horizontal
281-
: Orientation::vertical);
279+
auto res(options.horizontal ? Orientation::horizontal
280+
: Orientation::vertical);
282281
return Conv::toString(res);
283282
},
284283
.set =
@@ -293,8 +292,7 @@ Config::Accessors Config::initAccessors()
293292
{.get =
294293
[](const Options &options)
295294
{
296-
auto res(options.sorted ? Sort::byValue
297-
: Sort::none);
295+
auto res(options.sorted ? Sort::byValue : Sort::none);
298296
return Conv::toString(res);
299297
},
300298
.set =
@@ -308,7 +306,8 @@ Config::Accessors Config::initAccessors()
308306
{.get =
309307
[](const Options &options)
310308
{
311-
return Conv::toString(static_cast<bool>(options.reverse));
309+
return Conv::toString(
310+
static_cast<bool>(options.reverse));
312311
},
313312
.set =
314313
[](OptionsSetter &setter, const std::string &value)
@@ -325,14 +324,16 @@ Config::Accessors Config::initAccessors()
325324
.set =
326325
[](OptionsSetter &setter, const std::string &value)
327326
{
328-
setter.setAlign(Conv::parse<Base::Align::Type>(value));
327+
setter.setAlign(
328+
Conv::parse<Base::Align::Type>(value));
329329
}}});
330330

331331
res.insert({"split",
332332
{.get =
333333
[](const Options &options)
334334
{
335-
return Conv::toString(static_cast<bool>(options.splitted));
335+
return Conv::toString(
336+
static_cast<bool>(options.splitted));
336337
},
337338
.set =
338339
[](OptionsSetter &setter, const std::string &value)
@@ -350,7 +351,8 @@ Config::Accessors Config::initAccessors()
350351
.set =
351352
[](OptionsSetter &setter, const std::string &value)
352353
{
353-
setter.showTooltip(Conv::parse<std::optional<int>>(value));
354+
setter.showTooltip(
355+
Conv::parse<std::optional<int>>(value));
354356
}}});
355357

356358
return res;

0 commit comments

Comments
 (0)