@@ -79,6 +79,7 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
79
79
// Load the plugin entry.
80
80
auto pluginDir = std::filesystem::canonical (ll::plugin::getPluginsRoot () / manifest.name );
81
81
auto entryPath = pluginDir / manifest.entry ;
82
+ ENGINE_OWN_DATA ()->pluginFileOrDirPath = entryPath.string ();
82
83
83
84
// Try loadFile
84
85
try {
@@ -98,7 +99,11 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
98
99
plugin->onUnload ([](ll::plugin::Plugin& plugin) { return true ; });
99
100
plugin->onEnable ([](ll::plugin::Plugin& plugin) { return true ; });
100
101
plugin->onDisable ([](ll::plugin::Plugin& plugin) { return true ; });
101
- } catch (const std::exception& e) {
102
+ ExitEngineScope exit;
103
+ } catch (const Exception& e) {
104
+ EngineScope engineScope (scriptEngine);
105
+ logger.error (" Failed to load plugin {0}: {1}\n {2}" , manifest.name , e.message (), e.stacktrace ());
106
+ ExitEngineScope exit;
102
107
LLSERemoveTimeTaskData (&scriptEngine);
103
108
LLSERemoveAllEventListeners (&scriptEngine);
104
109
LLSERemoveCmdRegister (&scriptEngine);
@@ -109,18 +114,17 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
109
114
110
115
EngineManager::unregisterEngine (&scriptEngine);
111
116
112
- throw ;
117
+ return false ;
113
118
}
114
119
115
120
if (!addPlugin (manifest.name , plugin)) {
116
- throw std::runtime_error (fmt::format ( " failed to register plugin {}" , manifest.name ));
121
+ throw std::runtime_error (" Failed to register plugin {}" _tr ( manifest.name ));
117
122
}
118
123
119
124
return true ;
120
125
121
126
} catch (const std::exception& e) {
122
- logger.error (" failed to load plugin {}: {}" , manifest.name , e.what ());
123
- return false ;
127
+ logger.error (" Failed to load plugin {0}: {1}" , manifest.name , e.what ());
124
128
}
125
129
126
130
return true ;
0 commit comments