diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-19 15:21:51 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-19 15:21:51 +0000 |
commit | 1328556e3690aa7a6c6003373221c4cc914c1d4d (patch) | |
tree | 9937918b7ff76424726a949d34edbc1ba38f3dc0 /src/modules.cpp | |
parent | fe96061b003b7064b3e17c468a8851784890f7b8 (diff) |
Server::AddExtendedMode and Server::AddCommand will now throw exceptions when adding a bad mode or already existing command. If the module constructor does not handle this exception, this will abort the module's constructor, forbidding loading of modules which are unable to function (smart eh)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3246 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules.cpp')
-rw-r--r-- | src/modules.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index b1ac75f8f..fa1c9e7bd 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -475,7 +475,11 @@ void Server::Log(int level, std::string s) void Server::AddCommand(command_t *f) { - ServerInstance->Parser->CreateCommand(f); + if (!ServerInstance->Parser->CreateCommand(f)) + { + ModuleException err("Command "+std::string(f->command)+" already exists."); + throw (err); + } } void Server::SendMode(char **parameters, int pcnt, userrec *user) @@ -619,24 +623,28 @@ bool Server::AddExtendedMode(char modechar, int type, bool requires_oper, int pa { if (type == MT_SERVER) { - log(DEBUG,"*** API ERROR *** Modes of type MT_SERVER are reserved for future expansion"); + ModuleException e("Modes of type MT_SERVER are reserved for future expansion"); + throw(e); return false; } if (((params_when_on>0) || (params_when_off>0)) && (type == MT_CLIENT)) { - log(DEBUG,"*** API ERROR *** Parameters on MT_CLIENT modes are not supported"); + ModuleException e("Parameters on MT_CLIENT modes are not supported"); + throw(e); return false; } if ((params_when_on>1) || (params_when_off>1)) { - log(DEBUG,"*** API ERROR *** More than one parameter for an MT_CHANNEL mode is not yet supported"); + ModuleException e("More than one parameter for an MT_CHANNEL mode is not yet supported"); + throw(e); return false; } return DoAddExtendedMode(modechar,type,requires_oper,params_when_on,params_when_off); } else { - log(DEBUG,"*** API ERROR *** Muppet modechar detected."); + ModuleException e("Muppet modechar detected."); + throw(e); } return false; } |