Permalink
Browse files

Handlers are now wrapped in a try-catch

Handler calls are now wrapped in a try-catch to ensure that all handlers receive their callback in the case of an error.
  • Loading branch information...
1 parent 5a4d196 commit 5c66420e16948cd0a5d09fd3d386c3cec6f25c0d @rcythr rcythr committed Mar 31, 2013
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/swganh/event_dispatcher.cc
@@ -2,6 +2,7 @@
// See file LICENSE or go to http://swganh.com/LICENSE
#include "event_dispatcher.h"
+#include "logger.h"
#include <algorithm>
@@ -105,7 +106,14 @@ void EventDispatcher::InvokeCallbacks(const shared_ptr<EventInterface>& dispatch
end(event_type_iter->second),
[&dispatch_event] (const EventHandlerList::value_type& handler)
{
- handler.second(dispatch_event);
+ try
+ {
+ handler.second(dispatch_event);
+ }
+ catch(...)
+ {
+ DLOG(warning) << "A handler callback caused an exception.";
+ }
});
}
}
@@ -118,4 +126,4 @@ void EventDispatcher::Shutdown()
item.second.clear();
}
event_handlers_.clear();
-}
+}

0 comments on commit 5c66420

Please sign in to comment.