Skip to content

Commit e642729

Browse files
committed
added error for when no parameter fits
- added check to applyParameter that throws an error if the provided param does not match any known param - added to applyParameter unit test to ensure an error is thrown closes idaholab#27556
1 parent bf7a391 commit e642729

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

framework/src/utils/InputParameters.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "MultiMooseEnum.h"
1717
#include "ExecFlagEnum.h"
1818
#include "MooseObject.h"
19+
#include "FEProblem.h"
1920

2021
#include "libmesh/utility.h"
2122
#include "libmesh/simple_range.h"
@@ -1156,6 +1157,8 @@ InputParameters::applyParameter(const InputParameters & common,
11561157
// the parameter in the action
11571158
at(local_name)._hit_node = common.getHitNode(common_name);
11581159
}
1160+
else if (!local_exist && !common_exist)
1161+
mooseError("Attempted to apply invalid parameter \"", common_name, "\"");
11591162

11601163
// Enable deprecated message printing
11611164
_show_deprecated_message = true;

unit/src/InputParametersTest.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ TEST(InputParametersTest, applyParameter)
182182
p2.set<MultiMooseEnum>("enum") = "bar";
183183
p1.applyParameter(p2, "enum");
184184
EXPECT_TRUE(p1.get<MultiMooseEnum>("enum").contains("bar"));
185+
186+
// applyParameter should throw error if input parameter doesn't match any valid parameters
187+
EXPECT_THROW(p1.applyParameter(p2, "invalid_param"), std::exception);
185188
}
186189

187190
TEST(InputParametersTest, applyParametersVector)

0 commit comments

Comments
 (0)