From 2a9b0cdd30113ab4926f4b68350d619c015c89a3 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 19 Feb 2006 14:44:32 +0000 Subject: Added exception handling for module loading git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3240 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/modules.h | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'include') 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 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 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 }; -- cgit v1.2.3