diff --git a/src/tools/mana_auto_replay.cc b/src/tools/mana_auto_replay.cc index 97eae9f..b063e8e 100644 --- a/src/tools/mana_auto_replay.cc +++ b/src/tools/mana_auto_replay.cc @@ -438,28 +438,36 @@ int main(int argc, char *argv[]) try { - destSink = std::make_unique( - pluginHandle.get("mana_get_sink_plugin")()); + if (auto entryPoint = + pluginHandle.get("mana_get_sink_plugin")) + { + destSink = std::make_unique(entryPoint()); + } } catch (const std::exception &e) { - spdlog::debug("plugin {} is not a MANA_C_SINK_PLUGIN", pluginFile); - try + } + + if (!destSink) + { + if (auto entryPoint = pluginHandle.get("mana_get_plugin")) { - manaCppPlugin = std::unique_ptr( - pluginHandle.get("mana_get_plugin")()); + manaCppPlugin = std::unique_ptr(entryPoint()); + if (!manaCppPlugin) + throw std::runtime_error("plugin {}: mana_get_plugin() returned nullptr"); destSink = manaCppPlugin->makeSink(); } - catch (const std::exception &e) - { - std::cerr << fmt::format("Error loading plugin: {}\n", e.what()); - return 1; - } } } catch (const std::exception &e) { - std::cerr << fmt::format("Error loading plugin: {}\n", e.what()); + std::cerr << fmt::format("Error loading shared library {}: {}\n", pluginFile, e.what()); + return 1; + } + + if (!destSink) + { + std::cerr << fmt::format("Error: plugin {} does not provide a sink\n", pluginFile); return 1; } }