From b0903c020868f023c28a9c23859e9f16858a327a Mon Sep 17 00:00:00 2001 From: psychon Date: Sat, 23 Aug 2008 20:20:36 +0000 Subject: [PATCH] Handle a theoretically possible 'throw UNLOAD' in CModule::OnLoad() git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1164 726aef4b-f618-498e-8847-2d620e286838 --- Modules.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Modules.cpp b/Modules.cpp index 764f1f83..4e949d89 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -795,7 +795,15 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p pModule->SetDescription(GetDesc()); push_back(pModule); - if (!pModule->OnLoad(sArgs, sRetMsg)) { + bool bLoaded; + try { + bLoaded = pModule->OnLoad(sArgs, sRetMsg); + } catch (CModule::EModException e) { + bLoaded = false; + sRetMsg = "Caught an exception"; + } + + if (!bLoaded) { UnloadModule(sModule, sModPath); if (!sRetMsg.empty()) sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;