@@ -121,7 +121,7 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
121
121
logger.info (" loading plugin {}" , manifest.name );
122
122
123
123
if (hasPlugin (manifest.name )) {
124
- throw std::runtime_error (" plugin already loaded" );
124
+ return ll::makeStringError (" plugin already loaded" );
125
125
}
126
126
127
127
auto & scriptEngine = *EngineManager::newEngine (manifest.name );
@@ -166,7 +166,7 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
166
166
auto baseLibPath = self.getPluginDir () / " baselib" / BaseLibFileName;
167
167
auto baseLibContent = ll::file_utils::readFile (baseLibPath);
168
168
if (!baseLibContent) {
169
- throw std::runtime_error (fmt::format (" failed to read BaseLib at {}" , baseLibPath.string ()));
169
+ return ll::makeStringError (fmt::format (" failed to read BaseLib at {}" , baseLibPath.string ()));
170
170
}
171
171
scriptEngine.eval (baseLibContent.value ());
172
172
#endif
@@ -176,12 +176,12 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
176
176
ENGINE_OWN_DATA ()->pluginFileOrDirPath = entryPath.string ();
177
177
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
178
178
if (!PythonHelper::loadPluginCode (&scriptEngine, entryPath.string (), dirPath.string ())) {
179
- throw std::runtime_error (fmt::format (" failed to load plugin code" ));
179
+ return ll::makeStringError (fmt::format (" failed to load plugin code" ));
180
180
}
181
181
#endif
182
182
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
183
183
if (!NodeJsHelper::loadPluginCode (&scriptEngine, entryPath.string (), dirPath.string ())) {
184
- throw std::runtime_error (fmt::format (" failed to load plugin code" ));
184
+ return ll::makeStringError (fmt::format (" failed to load plugin code" ));
185
185
}
186
186
#endif
187
187
#if (defined LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS) || (defined LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
@@ -192,7 +192,7 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
192
192
// loadFile failed, try eval
193
193
auto pluginEntryContent = ll::file_utils::readFile (entryPath);
194
194
if (!pluginEntryContent) {
195
- throw std::runtime_error (fmt::format (" Failed to read plugin entry at {}" , entryPath.string ()));
195
+ return ll::makeStringError (fmt::format (" Failed to read plugin entry at {}" , entryPath.string ()));
196
196
}
197
197
scriptEngine.eval (pluginEntryContent.value ());
198
198
}
0 commit comments