summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-03-28 17:56:30 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-03-28 17:56:30 (GMT)
commit2848b093a1764d00ee9f2c0b92c1b50f38c62d71 (patch)
tree83df9cce1c9674dfb5628647430e6f902c65868c
parent8264fcbc3c907aebbcf22c0b452c56d371173c45 (diff)
downloadswift-2848b093a1764d00ee9f2c0b92c1b50f38c62d71.zip
swift-2848b093a1764d00ee9f2c0b92c1b50f38c62d71.tar.bz2
Catch all exceptions in event loop.
-rw-r--r--Swiften/EventLoop/EventLoop.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp
index 69d8abe..56bb6ac 100644
--- a/Swiften/EventLoop/EventLoop.cpp
+++ b/Swiften/EventLoop/EventLoop.cpp
@@ -12,8 +12,18 @@
#include <Swiften/Base/Log.h>
+
namespace Swift {
+inline void invokeCallback(const Event& event) {
+ try {
+ event.callback();
+ }
+ catch (const std::exception& e) {
+ std::cerr << "Uncaught exception in event loop: " << e.what() << std::endl;
+ }
+}
+
EventLoop::EventLoop() : nextEventID_(0), handlingEvents_(false) {
}
@@ -41,24 +51,14 @@ void EventLoop::handleEvent(const Event& event) {
}
if (doCallback) {
handlingEvents_ = true;
- try {
- event.callback();
- }
- catch (const boost::bad_function_call&) {
- SWIFT_LOG(error) << "Invalid function call" << std::endl;
- }
+ invokeCallback(event);
// Process events that were passed to handleEvent during the callback
// (i.e. through recursive calls of handleEvent)
while (!eventsToHandle_.empty()) {
Event nextEvent = eventsToHandle_.front();
eventsToHandle_.pop_front();
- try {
- nextEvent.callback();
- }
- catch (const boost::bad_function_call&) {
- SWIFT_LOG(error) << "Invalid function call" << std::endl;
- }
+ invokeCallback(nextEvent);
}
handlingEvents_ = false;
}