@@ -121,7 +121,7 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
121121 logger.info (" loading plugin {}" , manifest.name );
122122
123123 if (hasPlugin (manifest.name )) {
124- throw std::runtime_error (" plugin already loaded" );
124+ return ll::makeStringError (" plugin already loaded" );
125125 }
126126
127127 auto & scriptEngine = *EngineManager::newEngine (manifest.name );
@@ -166,7 +166,7 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
166166 auto baseLibPath = self.getPluginDir () / " baselib" / BaseLibFileName;
167167 auto baseLibContent = ll::file_utils::readFile (baseLibPath);
168168 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 ()));
170170 }
171171 scriptEngine.eval (baseLibContent.value ());
172172#endif
@@ -176,12 +176,12 @@ ll::Expected<> PluginManager::load(ll::plugin::Manifest manifest) {
176176 ENGINE_OWN_DATA ()->pluginFileOrDirPath = entryPath.string ();
177177#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
178178 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" ));
180180 }
181181#endif
182182#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
183183 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" ));
185185 }
186186#endif
187187#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) {
192192 // loadFile failed, try eval
193193 auto pluginEntryContent = ll::file_utils::readFile (entryPath);
194194 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 ()));
196196 }
197197 scriptEngine.eval (pluginEntryContent.value ());
198198 }
0 commit comments