mana auto replay: slightly improve plugin loading
it's still not great, error messages need to be better
This commit is contained in:
parent
0d862f401c
commit
0ef89eac14
1 changed files with 20 additions and 12 deletions
|
@ -438,28 +438,36 @@ int main(int argc, char *argv[])
|
|||
|
||||
try
|
||||
{
|
||||
destSink = std::make_unique<mana::ManaCSink>(
|
||||
pluginHandle.get<mana_sink_plugin_t()>("mana_get_sink_plugin")());
|
||||
if (auto entryPoint =
|
||||
pluginHandle.get<mana_sink_plugin_t()>("mana_get_sink_plugin"))
|
||||
{
|
||||
destSink = std::make_unique<mana::ManaCSink>(entryPoint());
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
spdlog::debug("plugin {} is not a MANA_C_SINK_PLUGIN", pluginFile);
|
||||
try
|
||||
}
|
||||
|
||||
if (!destSink)
|
||||
{
|
||||
manaCppPlugin = std::unique_ptr<mana::IManaPlugin>(
|
||||
pluginHandle.get<mana::IManaPlugin *()>("mana_get_plugin")());
|
||||
if (auto entryPoint = pluginHandle.get<mana::IManaPlugin *()>("mana_get_plugin"))
|
||||
{
|
||||
manaCppPlugin = std::unique_ptr<mana::IManaPlugin>(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());
|
||||
std::cerr << fmt::format("Error loading shared library {}: {}\n", pluginFile, e.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
||||
if (!destSink)
|
||||
{
|
||||
std::cerr << fmt::format("Error loading plugin: {}\n", e.what());
|
||||
std::cerr << fmt::format("Error: plugin {} does not provide a sink\n", pluginFile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue