diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-19 14:44:32 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-19 14:44:32 +0000 |
commit | 2a9b0cdd30113ab4926f4b68350d619c015c89a3 (patch) | |
tree | c756e270ca7d938d62d09c2ecee9d7c6be34af50 /include/modules.h | |
parent | 45fa01dc79889c68734a7629e8487917cf26a836 (diff) |
Added exception handling for module loading
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3240 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include/modules.h')
-rw-r--r-- | include/modules.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/include/modules.h b/include/modules.h index 1cdbbdeda..e1fb37621 100644 --- a/include/modules.h +++ b/include/modules.h @@ -93,7 +93,14 @@ typedef std::deque<userrec*> chanuserlist; #define FOREACH_MOD(y,x) if (Config->global_implementation[y] > 0) { \ for (int _i = 0; _i <= MODCOUNT; _i++) { \ if (Config->implement_lists[_i][y]) \ - modules[_i]->x ; \ + try \ + { \ + modules[_i]->x ; \ + } \ + catch (ModuleException modexcept) \ + { \ + log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \ + } \ } \ } @@ -107,10 +114,17 @@ typedef std::deque<userrec*> chanuserlist; MOD_RESULT = 0; \ for (int _i = 0; _i <= MODCOUNT; _i++) { \ if (Config->implement_lists[_i][y]) {\ - int res = modules[_i]->x ; \ - if (res != 0) { \ - MOD_RESULT = res; \ - break; \ + try \ + { \ + int res = modules[_i]->x ; \ + if (res != 0) { \ + MOD_RESULT = res; \ + break; \ + } \ + } \ + catch (ModuleException modexcept) \ + { \ + log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \ } \ } \ } \ @@ -272,6 +286,18 @@ class ExtMode : public classbase ExtMode(char mc, int ty, bool oper, int p_on, int p_off) : modechar(mc), type(ty), needsoper(oper), params_when_on(p_on), params_when_off(p_off), list(false) { }; }; + +class ModuleException +{ + public: + virtual ModuleException() {}; + virtual ~ModuleException() {}; + virtual char *GetReason() + { + return "Module threw an exception"; + } +}; + /** Priority types which can be returned from Module::Prioritize() */ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }; |