Skip to content

Commit

Permalink
core: Panic if requested module could not be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
caseif committed Jun 15, 2024
1 parent 27f792c commit f86bace
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
3 changes: 0 additions & 3 deletions engine/static/core/include/argus/core/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ namespace argus {
*
* @attention This must be called before any other interaction with the
* engine takes place.
*
* @throw std::invalid_argument If any of the requested modules (or their
* dependencies) cannot be loaded.
*/
void initialize_engine(void);

Expand Down
6 changes: 1 addition & 5 deletions engine/static/core/include/argus/core/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ namespace argus {
*
* @attention For convenience, the macro REGISTER_ARGUS_MODULE registers an
* entry point which invokes this function automatically.
*
* @throw std::invalid_argument If a module with the given ID is already
* registered.
*/
void register_dynamic_module(const std::string &id, LifecycleUpdateCallback lifecycle_callback,
const std::vector<std::string>& dependencies = {});
Expand All @@ -212,8 +209,7 @@ namespace argus {
*
* @param module_id The ID of the dynamic module to enable.
*
* @throw std::invalid_argument If no dynamic module with the given ID is
* currently registered.
* @return Whether the module was successfully enabled.
*/
bool enable_dynamic_module(const std::string &module_id);

Expand Down
8 changes: 5 additions & 3 deletions engine/static/core/src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ namespace argus {
if (dependent_chain.empty()) {
Logger::default_logger().warn("Module \"%s\" requested more than once.", module_id.c_str());
}
return false;
return true;
}
}

Expand Down Expand Up @@ -334,7 +334,7 @@ namespace argus {

g_enabled_dyn_modules_staging.insert({ module_id, it->second });

Logger::default_logger().info("Enabled dynamic module %s.", module_id.c_str());
Logger::default_logger().info("Enabled dynamic module %s", module_id.c_str());

return true;
}
Expand All @@ -357,7 +357,9 @@ namespace argus {
all_modules.insert({ found_static->id });
all_modules.insert(found_static->dependencies.begin(), found_static->dependencies.end());
} else {
enable_dynamic_module(module_id);
if (!enable_dynamic_module(module_id)) {
crash("Failed to load required module %s", module_id.c_str());
}
}
}

Expand Down

0 comments on commit f86bace

Please sign in to comment.