From 877eb6d767ef653f9c7e1555495da8b1e5457ca0 Mon Sep 17 00:00:00 2001 From: "Yu-Hsiang M. Tsai" Date: Thu, 17 Aug 2023 11:12:12 +0200 Subject: [PATCH] throw gko::Error --- core/config/config.cpp | 5 ++++- core/config/dispatch.hpp | 3 ++- core/config/stop_config.cpp | 3 +++ include/ginkgo/core/config/registry.hpp | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/config/config.cpp b/core/config/config.cpp index 5a278861ef9..abdb5b71fd4 100644 --- a/core/config/config.cpp +++ b/core/config/config.cpp @@ -36,6 +36,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include + + namespace gko { namespace config { @@ -55,7 +58,7 @@ std::unique_ptr build_from_config( config.at("Type").get_data()); return func(config, context, exec, td); } - return nullptr; + GKO_INVALID_STATE("Should contain Type property"); } diff --git a/core/config/dispatch.hpp b/core/config/dispatch.hpp index 33a466bdde4..e6e8f1d0b58 100644 --- a/core/config/dispatch.hpp +++ b/core/config/dispatch.hpp @@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include #include #include #include @@ -75,7 +76,7 @@ std::unique_ptr dispatch(std::string str, const pnode& config, const type_descriptor& td, syn::type_list<>, List... list) { - throw std::runtime_error("Not Found"); + GKO_INVALID_STATE("Can not figure out the actual type"); } /** diff --git a/core/config/stop_config.cpp b/core/config/stop_config.cpp index 45fb0552a4f..5d5774585f2 100644 --- a/core/config/stop_config.cpp +++ b/core/config/stop_config.cpp @@ -30,6 +30,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *************************************************************/ +#include #include #include #include @@ -41,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "core/config/config.hpp" #include "core/config/dispatch.hpp" + namespace gko { namespace config { @@ -74,6 +76,7 @@ stop::mode get_mode(const std::string& str) } else if (str == "rhs_norm") { return stop::mode::rhs_norm; } + GKO_INVALID_STATE("Not valid " + str); } diff --git a/include/ginkgo/core/config/registry.hpp b/include/ginkgo/core/config/registry.hpp index 3b02b2b6c1e..ac58696b7af 100644 --- a/include/ginkgo/core/config/registry.hpp +++ b/include/ginkgo/core/config/registry.hpp @@ -35,6 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include #include #include #include