From 5e86f62a9809c35fc4d6ed5b41b4c4aa3534f336 Mon Sep 17 00:00:00 2001 From: iTrooz Date: Tue, 12 Sep 2023 12:00:00 +0200 Subject: [PATCH] fix: Handle exceptions thrown by providers on loadSettings() (#1307) --- plugins/builtin/source/content/providers.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/builtin/source/content/providers.cpp b/plugins/builtin/source/content/providers.cpp index 894a5b102..f41b190cf 100644 --- a/plugins/builtin/source/content/providers.cpp +++ b/plugins/builtin/source/content/providers.cpp @@ -69,11 +69,19 @@ namespace hex::plugin::builtin { } provider->setID(id); - provider->loadSettings(providerSettings.at("settings")); - if (!provider->open() || !provider->isAvailable() || !provider->isReadable()) { - providerWarnings[provider] = provider->getErrorMessage(); - } else - EventManager::post(provider); + bool loaded = false; + try { + provider->loadSettings(providerSettings.at("settings")); + loaded = true; + } catch (const std::exception &e){ + providerWarnings[provider] = e.what(); + } + if (loaded) { + if (!provider->open() || !provider->isAvailable() || !provider->isReadable()) { + providerWarnings[provider] = provider->getErrorMessage(); + } else + EventManager::post(provider); + } } std::string warningMsg;