From 8c76e7cc11c4e52007a48a9d11163c58d6753c83 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Thu, 13 Nov 2025 16:56:36 -0800 Subject: [PATCH] container: root: macro: common: throw if invalid loading path - Fixes silent failure when attempting to load non-existent/invalid path - Applies to any macro, plugin or path that's loaded through this class --- container/src/root/macro/common/utility.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/container/src/root/macro/common/utility.hh b/container/src/root/macro/common/utility.hh index 83929d4..e819b1d 100644 --- a/container/src/root/macro/common/utility.hh +++ b/container/src/root/macro/common/utility.hh @@ -24,6 +24,7 @@ #define CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_ #include +#include #include #include #include @@ -72,6 +73,18 @@ class Command final //! \brief Load given file path static void load(const std::string& path) { + std::filesystem::path p(path); + if (!std::filesystem::exists(p)) + { + throw std::runtime_error( + std::string{"'" + path + "' does not exist!"}.c_str()); + } + if (!std::filesystem::is_regular_file(p)) + { + throw std::runtime_error( + std::string{"'" + path + "' is not a regular file!"}.c_str()); + } + std::string cmd{".L " + path}; Command::cmd_handler({cmd}); }