Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions core/config/config.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand All @@ -22,9 +22,13 @@ deferred_factory_parameter<gko::LinOpFactory> parse(const pnode& config,
const type_descriptor& td)
{
if (auto& obj = config.get("type")) {
auto func = detail::registry_accessor::get_build_map(context).at(
obj.get_string());
return func(config, context, td);
const auto& build_map =
detail::registry_accessor::get_build_map(context);
auto search = build_map.find(obj.get_string());
if (search != build_map.end()) {
GKO_INVALID_CONFIG_VALUE("type", obj.get_string());
}
return search->second(config, context, td);
}
GKO_MISSING_CONFIG_ENTRY("type");
}
Expand Down
9 changes: 9 additions & 0 deletions core/test/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ TEST_F(Config, GenerateObjectWithCustomBuild)
}


TEST_F(Config, ThrowWhenKeyIsInvalidInType)
{
auto reg = registry();
pnode p{{{"type", pnode{"Invalid"}}}};

ASSERT_THROW(parse(p, reg), gko::InvalidStateError);
}


TEST_F(Config, ThrowWhenKeyIsInvalidInCriterion)
{
auto reg = registry();
Expand Down
Loading