41 throw Exception(
"plugins.load: empty path");
42 if (loaded_.count(
path))
45 if (!registration.ok())
throw Exception(
"plugins.load: nested plugin loading is not supported");
48 HMODULE mod = LoadLibraryA(
path.c_str());
50 const DWORD
error = GetLastError();
51 rollbackPluginRegistration(
"plugin library load failed");
52 throw Exception(
"plugins.load: LoadLibrary failed for '%s' (err=%lu)",
path.c_str(),
55 auto init =
reinterpret_cast<PluginInitFn>(GetProcAddress(mod,
"eve_plugin_init"));
57 rollbackPluginRegistration(
"plugin entry point is missing");
59 throw Exception(
"plugins.load: missing eve_plugin_init in '%s'",
path.c_str());
65 rollbackPluginRegistration(
"plugin initializer threw");
67 throw Exception(
"plugins.load: eve_plugin_init threw for '%s'",
path.c_str());
70 rollbackPluginRegistration(
"plugin initializer returned failure");
72 throw Exception(
"plugins.load: eve_plugin_init returned %d for '%s'", rc,
path.c_str());
75 void* mod = dlopen(
path.c_str(), RTLD_NOW | RTLD_GLOBAL);
77 rollbackPluginRegistration(
"plugin library load failed");
78 throw Exception(
"plugins.load: dlopen failed for '%s': %s",
path.c_str(), dlerror());
81 auto init =
reinterpret_cast<PluginInitFn>(dlsym(mod,
"eve_plugin_init"));
82 const char* err = dlerror();
83 if (err !=
nullptr || !init) {
84 const std::string
error = err ? err :
"";
85 rollbackPluginRegistration(
"plugin entry point is missing");
87 throw Exception(
"plugins.load: missing eve_plugin_init in '%s'%s%s",
path.c_str(),
94 rollbackPluginRegistration(
"plugin initializer threw");
96 throw Exception(
"plugins.load: eve_plugin_init threw for '%s'",
path.c_str());
99 rollbackPluginRegistration(
"plugin initializer returned failure");
101 throw Exception(
"plugins.load: eve_plugin_init returned %d for '%s'", rc,
path.c_str());
106 if (!registrationResult.ok()) {
107 const std::string registrationError = registrationResult.status().describe();
113 throw Exception(
"plugins.load: %s in '%s'", registrationError.c_str(),
path.c_str());
118 throw Exception(
"plugins.load: expose_pending failed after loading '%s'; plugin retained",