summaryrefslogtreecommitdiff
path: root/src/modules.c
diff options
context:
space:
mode:
authorRobin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-08 00:42:55 +0000
committerRobin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-08 00:42:55 +0000
commit7181dc35ce0f2d2a2bf2d2bd0d36a690c1cc6b95 (patch)
tree928c3aa5dcf3385c4428adfffa47a449d096fae8 /src/modules.c
parent11a99c885a85fc7c8f05a5a49a99ae8c02dc2f92 (diff)
Catch ModuleException thrown from module constructors, and halt load if one is recieved.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1582 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules.c')
-rw-r--r--src/modules.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/modules.c b/src/modules.c
index 393dc38c5..2b411e4d5 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -365,6 +365,7 @@ Module::Module(const std::string &mname, const std::string &creator)
this->hostHelp = NULL;
this->helpHelp = NULL;
this->type = THIRD;
+ this->handle = NULL;
for (int i = 0; i < NUM_LANGS; i++)
{
@@ -391,8 +392,11 @@ Module::~Module()
if (this->version)
free(this->version);
- if ((ano_modclose(this->handle)) != 0)
- alog("%s", ano_moderr());
+ if (this->handle)
+ {
+ if ((ano_modclose(this->handle)) != 0)
+ alog("%s", ano_moderr());
+ }
/*
* No need to free our cmd/msg list, as they will always be empty by the module is destroyed
@@ -666,16 +670,25 @@ int loadModule(const std::string &modname, User * u)
mod_current_module_name = modname.c_str();
- /* Create module.
- * XXX: we need to handle ModuleException throws here.
- */
+ /* Create module. */
std::string nick;
if (u)
nick = u->nick;
else
nick = "";
- Module *m = func(nick);
+ Module *m;
+
+ try
+ {
+ m = func(nick);
+ }
+ catch (ModuleException &ex)
+ {
+ alog("Error while loading %s: %s", modname.c_str(), ex.GetReason());
+ return MOD_STOP;
+ }
+
mod_current_module = m;
mod_current_user = u;
m->filename = sstrdup(buf);