From 76a52d4556b46f5408372650431b247ce8bc3504 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Tue, 5 Feb 2019 15:57:18 +0100 Subject: [PATCH] [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. --- ProcessLib/Parameter/ConstantParameter.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ProcessLib/Parameter/ConstantParameter.cpp b/ProcessLib/Parameter/ConstantParameter.cpp index 94d7f6929f3..12ac93c33fe 100644 --- a/ProcessLib/Parameter/ConstantParameter.cpp +++ b/ProcessLib/Parameter/ConstantParameter.cpp @@ -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]); } } -- GitLab