class documentation

class ErrorDialog(Gtk.MessageDialog): (source)

Known subclasses: zim.gui.pageview.SavePageErrorDialog

View In Hierarchy

The is the main class for error dialogs in zim. It not only presents the error to the user, but also takes care of logging it. So the error dialog can be used as a generic catch all for exceptions in the user interface. The way the error is shown depends on the class of the exception:

For exceptions that inherit from zim.errors.Error or EnvironmentError (e.g. OSError or IOError) a normal error dialog will be shown. This covers errors that can can occur in normal usage. As a special case the "filename" attribute of Environment errors is used and added to the error message.

On the other all exceptions that do not inherit from these classes (so all standard in exceptions like AssertionError, KeyError etc.) are considered the result of bugs and the dialog will say: "Looks like you found a bug" and show a stack trace.

Note
in menu action handlers you typically do not need to catch exceptions with an error dialog. The standard menu wrapper takes care of that.
Method __init__ Constructor
Method assert_response_ok Undocumented
Method do_response_ok Response handler for the 'OK' button @implementation: optional to be implemented by sub-classes that want to run some action after presenting the error.
Method get_debug_text Get the text to show in the log of a "You found a bug" dialog. Includes zim version info and traceback info.
Method run Runs the dialog and destroys it directly.
Instance Variable do_logging Undocumented
Instance Variable error Undocumented
Instance Variable showing_trace Undocumented
Method _run Undocumented
def __init__(self, parent, error, exc_info=None, do_logging=True, buttons=Gtk.ButtonsType.CLOSE): (source)
Constructor
Parameters
parenteither a parent window or dialog or None
errorthe actual error, either an Exception object (including instances of zim.errors.Error), a string with the error description, or a 2-tuple of the short message and the longer description as strings. Using a tuple here will give a better looking dialog over using a simple string.
exc_infothis is an optional argument that takes the result of sys.exc_info(). This parameter is not necessary in most cases where the dialog is run while the exception is still in scope. One reason to pass it on explicitly is the handling of errors from an async operation in the main tread.
do_loggingif True also log the error, if False assume someone else already did
buttons

a constant controlling what kind of buttons the dialog will have. One of:

  • None or Gtk.ButtonsType.NONE: for dialogs taking care of constructing the buttons themselves
  • Gtk.ButtonsType.OK_CANCEL: Render Ok and Cancel
  • Gtk.ButtonsType.CLOSE: Only set a Close button
def assert_response_ok(self): (source)

Undocumented

def do_response_ok(self): (source)
Response handler for the 'OK' button
Unknown Field: implementation
optional to be implemented by sub-classes that want to run some action after presenting the error.
def get_debug_text(self, exc_info=None): (source)
Get the text to show in the log of a "You found a bug" dialog. Includes zim version info and traceback info.
Parameters
exc_infothis is an optional argument that takes the result of sys.exc_info()
Returns
debug log as string
def run(self): (source)
Runs the dialog and destroys it directly.
do_logging = (source)

Undocumented

error = (source)

Undocumented

showing_trace: bool = (source)

Undocumented

def _run(self): (source)

Undocumented