# HG changeset patch # User Erik Grinaker # Date 1092135879 0 # Node ID 96a566d69e06e62939a6eaab00427f807008b3e2 # Parent 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 display unhandled exceptions in a dialog diff -r 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 -r 96a566d69e06e62939a6eaab00427f807008b3e2 ChangeLog --- a/ChangeLog Mon Aug 09 07:52:51 2004 +0000 +++ b/ChangeLog Tue Aug 10 11:04:39 2004 +0000 @@ -1,6 +1,14 @@ Revelation changelog ----------------[ 2004-08-08 : 0.3.2 ]--------------- +---------------[ xxxx-xx-xx : 0.3.3 ]--------------- + +2004-08-10 Erik Grinaker + + * added an exception handler which displays a dialog with + a tracebacck whenever an unhandled exception occurs + + +---------------[ 2004-08-09 : 0.3.2 ]--------------- 2004-08-09 Erik Grinaker diff -r 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 -r 96a566d69e06e62939a6eaab00427f807008b3e2 NEWS --- a/NEWS Mon Aug 09 07:52:51 2004 +0000 +++ b/NEWS Tue Aug 10 11:04:39 2004 +0000 @@ -1,3 +1,10 @@ +xxxx-xx-xx: Revelation 0.3.3 +============================ + +New features: +- unknown errors are reported in a dialog with a error call traceback + + 2004-08-09: Revelation 0.3.2 ============================ diff -r 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 -r 96a566d69e06e62939a6eaab00427f807008b3e2 TODO --- a/TODO Mon Aug 09 07:52:51 2004 +0000 +++ b/TODO Tue Aug 10 11:04:39 2004 +0000 @@ -9,6 +9,8 @@ be atomic (can't call add_entry() etc directly, since it triggers the signal repeatedly) - quicksearch entry in the toolbar +- add import/export of PasswordSafe files +- bug: entry-description aren't stored in the entry object 0.4.x: - will introduce a gnome 2.6 dependency diff -r 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 -r 96a566d69e06e62939a6eaab00427f807008b3e2 src/lib/dialog.py --- a/src/lib/dialog.py Mon Aug 09 07:52:51 2004 +0000 +++ b/src/lib/dialog.py Tue Aug 10 11:04:39 2004 +0000 @@ -23,7 +23,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -import gtk, gnome.ui, revelation, time, gconf +import gtk, gnome.ui, revelation, time, gconf, pango RESPONSE_NEXT = 10 RESPONSE_PREVIOUS = 11 @@ -730,6 +730,25 @@ +class Exception(Error): + "A dialog for displaying unhandled errors (exceptions)" + + def __init__(self, parent, traceback): + Error.__init__( + self, parent, "Unknown error", + "An unknown error occured. Please report the text below to the Revelation developers, along with what you were doing that may have caused the error." + ) + + textview = revelation.widget.TextView(traceback) + textview.modify_font(pango.FontDescription("Monospace")) + + scrolledwindow = revelation.widget.ScrolledWindow(textview) + scrolledwindow.set_size_request(-1, 120) + + self.contents.pack_start(scrolledwindow) + + + class Find(Property): "A dialog for searching for entries" diff -r 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 -r 96a566d69e06e62939a6eaab00427f807008b3e2 src/lib/io.py --- a/src/lib/io.py Mon Aug 09 07:52:51 2004 +0000 +++ b/src/lib/io.py Tue Aug 10 11:04:39 2004 +0000 @@ -23,7 +23,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -import revelation, gobject, os, os.path +import revelation, gobject, os, os.path, traceback, StringIO class DetectError(Exception): @@ -175,3 +175,12 @@ fp.flush() fp.close() + +def trace_exception(type, value, tb): + "Returns an exception traceback as a string" + + trace = StringIO.StringIO() + traceback.print_exception(type, value, tb, None, trace) + + return trace.getvalue() + diff -r 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 -r 96a566d69e06e62939a6eaab00427f807008b3e2 src/lib/widget.py --- a/src/lib/widget.py Mon Aug 09 07:52:51 2004 +0000 +++ b/src/lib/widget.py Tue Aug 10 11:04:39 2004 +0000 @@ -278,6 +278,21 @@ +class TextView(gtk.TextView): + "A text view" + + def __init__(self, text = None, buffer = None): + gtk.TextView.__init__(self, buffer) + + if text is not None: + self.get_buffer().set_text(text) + + self.set_editable(gtk.FALSE) + self.set_wrap_mode(gtk.WRAP_NONE) + self.set_cursor_visible(gtk.FALSE) + + + class TreeStore(gtk.TreeStore): "An enhanced gtk.TreeStore" diff -r 02fc1b2867d4a7aa78b8fde50e854cafb4860d49 -r 96a566d69e06e62939a6eaab00427f807008b3e2 src/revelation --- a/src/revelation Mon Aug 09 07:52:51 2004 +0000 +++ b/src/revelation Tue Aug 10 11:04:39 2004 +0000 @@ -32,6 +32,8 @@ "Main application class" def __init__(self): + sys.excepthook = self.__cb_exception + gnome.init(revelation.APPNAME, revelation.APPNAME) revelation.widget.App.__init__(self, revelation.APPNAME) @@ -49,6 +51,7 @@ self.__init_states() + # init methods def __init_facilities(self): "Sets up various application facilities" @@ -194,6 +197,15 @@ + # exception callback + def __cb_exception(self, type, value, trace): + "Callback for unhandled exceptions" + + traceback = revelation.io.trace_exception(type, value, trace) + revelation.dialog.Exception(self, traceback).run() + sys.exit(1) + + # config callbacks def __cb_config_statusbar(self, config, value, data): "Config callback for statusbar changes"