[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] errors and middleware (was 0.2)

From: Karsten Hilbert
Subject: Re: [Gnumed-devel] errors and middleware (was 0.2)
Date: Sat, 24 Jun 2006 19:33:37 +0200
User-agent: Mutt/1.5.11+cvs20060403

On Sat, Jun 24, 2006 at 10:32:20PM +1000, Ian Haywood wrote:

> Currently all errors must be handled at every point in the stack.
I don't like this either.

> however
> a lot of the time errors are generated at the top (in the database layer)
I agree.

> and handled right at the bottom (in GUI code), with exceptions they can pass
> through easily and leave the intervening code uncluttered.
I agree. One problem is that they do not (yet) pass through
beyond the event handler they are raised in. Which you know.
Your suggestion to call something like
global_error(the_error) sounds OK to me.

If we can find a good way to "attach" more meaning to the
exception that's propagating to the GUI layer I am totally
fine with this solution. Let us get 0.2 out the door and
then implement what you suggest.

> Exceptions also make it easier to have common error-handling code in the GUI 
> layer.
> IMHO we should do something like this.
>     def error (self):
>         """
>         Handle the current exception
>         """
>         exc_class, exc = sys.exc_info ()[:2]
>         if issubclass (exc_class, GnuMedError):
>             title = exc.title
>             s = exc.text
>         elif issubclass (exc_class, dbapi.OperationalError):
>             title = "Database Problem"
>             s = str(exc)
>         else:
>             title = "General Error"
>             s = str(exc)
>         gmLog.Log (str (exc))
>         wx.MessageBox (s, title, style=wx.OK)
> then every GUI event handler has simply.
> try:
> except:
>    self.error ()

This needs refinement in many aspects but I perfectly like
the approach. As I have said before.

Please let us do it in 0.3.

GPG key ID E4071346 @
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

reply via email to

[Prev in Thread] Current Thread [Next in Thread]