Skip to content
Snippets Groups Projects
Commit 76a52d45 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL] Improve error for ConstantParameter parsing.

In case of multiple values given under the <value>
tag, the error was not conclusive. Parsing the value
as vector, allows checking of the size now.
parent fd3f495d
No related branches found
No related tags found
No related merge requests found
......@@ -25,12 +25,20 @@ std::unique_ptr<ParameterBase> createConstantParameter(
// then required tag 'values'.
{
//! \ogs_file_param{prj__parameters__parameter__Constant__value}
auto const value = config.getConfigParameterOptional<double>("value");
auto const value =
config.getConfigParameterOptional<std::vector<double>>("value");
if (value)
{
DBUG("Using value %g for constant parameter.", *value);
return std::make_unique<ConstantParameter<double>>(name, *value);
if (value->size() != 1)
{
OGS_FATAL(
"Expected to read exactly one value, but %d were given.",
value->size());
}
DBUG("Using value %g for constant parameter.", (*value)[0]);
return std::make_unique<ConstantParameter<double>>(name,
(*value)[0]);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment