← Back to team overview

bzr-explorer-dev team mailing list archive

Re: exception handling in bzr-explorer

 

On Thu, Jul 23, 2009 at 5:19 PM, Ian
Clatworthy<ian.clatworthy@xxxxxxxxxxxxxxxx> wrote:
> Gary,
>
> I'm pretty keen for you to re-use qbzr's exception catching logic in
> explorer when you get a chance. Basically, if someone is running from an
> icon on their desktop (no shell displayed on Ubuntu), then exceptions
> need to be shown, not silently disappear.
>
> Shall a raise a bug for this or is it a 5 minute fix for you (say)?
>
> Ian C.


Ok I have done so.

Please note the following:  The exception hook that I have added only
catches exceptions raised by code run in the main loop (app.exec_()).
Anything raised in cmd_explorer.run (including
QExplorerMainWindow.__init__ and QExplorerMainWindow.show) will go to
the std bzr error handler.

By default the error dialog shows and Ignore and Close buttons. Ignore
dismisses the dialog, and does nothing else, but Close will close the
whole app. This is the behavoiur you want for unexpected exceptions.
There will be times when you want to alter this behaviour. When the
exception is expected, maybe because you are checking user input, or
you are connecting to a remote location, and you want to inform the
user about the error, but you don't want to shut down the whole app.
To do this:

from bzrlib.plugins.qbzr.lib.trace import (

   report_exception,

   SUB_LOAD_METHOD)


try:

    Do somthing that may raise and error.
except:

    report_exception(type=SUB_LOAD_METHOD, window=self.window())

    return


or you can just decorate a method:

from bzrlib.plugins.qbzr.lib.trace import (
   reports_exception,
   SUB_LOAD_METHOD)

@reports_exception(type = SUB_LOAD_METHOD)
def do_somthing():


At the moment, if there is an error, it tells the user to log it at
https://bugs.launchpad.net/bzr/+filebug. I plan to make it possible to
change that, so that we can set it to /qbzr/+filebug and
bzr-explorer/+filebug appropriately.



References