aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-06 18:43:51 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-06 18:43:51 +0000
commitc986664dfa64af088060cda66c5b14d37cf77a58 (patch)
tree853fe5f079063776501e18e440266dde921f83fa
parent60a64c022653cad3a66f656b907bd340e9ce097c (diff)
downloadpaludis-c986664dfa64af088060cda66c5b14d37cf77a58.tar.gz
paludis-c986664dfa64af088060cda66c5b14d37cf77a58.tar.xz
r3350@snowflake: ciaranm | 2007-06-06 19:43:36 +0100
Handle exceptions
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/threaded_window.cc29
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/threaded_window.hh3
2 files changed, 31 insertions, 1 deletions
diff --git a/src/clients/gtkpaludis/libgtkpaludis/threaded_window.cc b/src/clients/gtkpaludis/libgtkpaludis/threaded_window.cc
index 772f941..e8a18cf 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/threaded_window.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/threaded_window.cc
@@ -5,6 +5,9 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/tr1_functional.hh>
+#include <gtkmm/dialog.h>
+#include <gtkmm/messagedialog.h>
+#include <gtkmm/stock.h>
#include <unistd.h>
#include <algorithm>
#include <list>
@@ -89,7 +92,20 @@ ThreadedWindow::paludis_thread_action_then_sensitise(const sigc::slot<void> & a,
if (! status_message.empty())
gui_thread_action(sigc::bind(sigc::mem_fun(this, &ThreadedWindow::push_status_message), status_message));
- a();
+ try
+ {
+ a();
+ }
+ catch (const Exception & e)
+ {
+ gui_thread_action(sigc::bind(sigc::mem_fun(this, &ThreadedWindow::notify_exception),
+ std::string(e.message()), std::string(e.what()), std::string(e.backtrace("\n"))));
+ }
+ catch (const std::exception & e)
+ {
+ gui_thread_action(sigc::bind(sigc::mem_fun(this, &ThreadedWindow::notify_exception),
+ std::string(""), std::string(e.what()), std::string("")));
+ }
if (! status_message.empty())
gui_thread_action(sigc::mem_fun(this, &ThreadedWindow::pop_status_message));
@@ -179,3 +195,14 @@ ThreadedWindow::do_set_sensitive(const bool v)
set_sensitive(v);
}
+void
+ThreadedWindow::notify_exception(const std::string & message, const std::string & what,
+ const std::string & backtrace)
+{
+ Gtk::MessageDialog dialog(*this, "Caught exception", false, Gtk::MESSAGE_ERROR,
+ Gtk::BUTTONS_OK);
+ dialog.set_title("Caught exception '" + what + "'");
+ dialog.set_secondary_text(backtrace + "Caught exception '" + message + "' (" + what + ")");
+ dialog.run();
+}
+
diff --git a/src/clients/gtkpaludis/libgtkpaludis/threaded_window.hh b/src/clients/gtkpaludis/libgtkpaludis/threaded_window.hh
index 000fd8a..e4ce78c 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/threaded_window.hh
+++ b/src/clients/gtkpaludis/libgtkpaludis/threaded_window.hh
@@ -39,6 +39,9 @@ namespace gtkpaludis
void paludis_thread_action(const sigc::slot<void> &, const std::string & status_message);
void gui_thread_action(const sigc::slot<void> &);
+ virtual void notify_exception(const std::string & message, const std::string & what,
+ const std::string & backtrace);
+
paludis::Environment * environment();
};
}