diff --git a/src/internal/mana_lib.hpp b/src/internal/mana_lib.hpp index 4734aa3..6392d36 100644 --- a/src/internal/mana_lib.hpp +++ b/src/internal/mana_lib.hpp @@ -367,19 +367,26 @@ PluginWrapper load_mana_plugin(const std::string &filename, PluginWrapper result; result.pluginHandle = boost::dll::shared_library(filename, boost::dll::load_mode::rtld_global); - if (auto entryPoint = result.pluginHandle.get("mana_get_sink_plugin")) + try { - std::vector argv; - for (const auto &arg: pluginArgs) - argv.push_back(arg.data()); - result.destSink = std::make_unique(entryPoint(), argv.size(), argv.data()); + if (auto entryPoint = result.pluginHandle.get("mana_get_sink_plugin")) + { + std::vector argv; + for (const auto &arg: pluginArgs) + argv.push_back(arg.data()); + result.destSink = + std::make_unique(entryPoint(), argv.size(), argv.data()); + } } - else if (auto entryPoint = result.pluginHandle.get("mana_get_plugin")) + catch (const std::exception &e) { - result.manaCppPlugin = std::unique_ptr(entryPoint()); - if (!result.manaCppPlugin) - throw std::runtime_error("plugin {}: mana_get_plugin() returned nullptr"); - result.destSink = result.manaCppPlugin->makeSink(); + if (auto entryPoint = result.pluginHandle.get("mana_get_plugin")) + { + result.manaCppPlugin = std::unique_ptr(entryPoint()); + if (!result.manaCppPlugin) + throw std::runtime_error("plugin {}: mana_get_plugin() returned nullptr"); + result.destSink = result.manaCppPlugin->makeSink(); + } } return result;