[niepce] Added exception handling for the notifications.
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Added exception handling for the notifications.
- Date: Wed, 10 Apr 2013 02:53:18 +0000 (UTC)
commit 04ab73984404657a91eb499cd79d4b0638c99e74
Author: Hubert Figuière <hub figuiere net>
Date: Wed Feb 27 23:34:11 2013 -0500
Added exception handling for the notifications.
src/niepce/notificationcenter.cpp | 46 +++++++++++++++++++++---------------
1 files changed, 27 insertions(+), 19 deletions(-)
---
diff --git a/src/niepce/notificationcenter.cpp b/src/niepce/notificationcenter.cpp
index 439cc54..a53ac71 100644
--- a/src/niepce/notificationcenter.cpp
+++ b/src/niepce/notificationcenter.cpp
@@ -1,7 +1,7 @@
/*
* niepce - niepce/notificationcenter.hpp
*
- * Copyright (C) 2009 Hubert Figuiere
+ * Copyright (C) 2009, 2013 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,36 +25,44 @@
namespace niepce {
-
NotificationCenter::NotificationCenter()
{
- subscribe(NOTIFICATION_LIB,
+ subscribe(NOTIFICATION_LIB,
sigc::mem_fun(*this, &NotificationCenter::dispatch_notification));
- subscribe(NOTIFICATION_THUMBNAIL,
+ subscribe(NOTIFICATION_THUMBNAIL,
sigc::mem_fun(*this, &NotificationCenter::dispatch_notification));
}
void NotificationCenter::dispatch_notification(const fwk::Notification::Ptr &n)
{
- switch(n->type()) {
-
- case NOTIFICATION_LIB:
- {
- eng::LibNotification ln
- = boost::any_cast<eng::LibNotification>(n->data());
- signal_lib_notification (ln);
- break;
+ try {
+ switch(n->type()) {
+ case NOTIFICATION_LIB:
+ {
+ eng::LibNotification ln
+ = boost::any_cast<eng::LibNotification>(n->data());
+ signal_lib_notification (ln);
+ break;
+ }
+ case NOTIFICATION_THUMBNAIL:
+ {
+ eng::ThumbnailNotification tn
+ = boost::any_cast<eng::ThumbnailNotification>(n->data());
+ signal_thumbnail_notification (tn);
+ break;
+ }
+ default:
+ break;
+ }
}
- case NOTIFICATION_THUMBNAIL:
+ catch(const boost::bad_any_cast & e)
{
- eng::ThumbnailNotification tn
- = boost::any_cast<eng::ThumbnailNotification>(n->data());
- signal_thumbnail_notification (tn);
- break;
+ ERR_OUT("improper notification data: %s", e.what());
}
- default:
- break;
+ catch(...)
+ {
+ ERR_OUT("unknown exception");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]