[wxPython-users] Better exception handling
Jorgen Bodde
jorgen.maillist at gmail.com
Sat Jun 30 06:56:44 PDT 2007
Hi Riaan,
Awesome! I added this to my main code in the .pyw variant of my app,
and it works as a charm!
Thanks!
- Jorgen
On 6/30/07, Riaan Booysen <riaan at e.co.za> wrote:
> Hi Jorgen,
>
> Jorgen Bodde wrote:
> > Hi All,
> >
> > I love wxPython! One thing that worries me for my end-users is the
> > inability to see potential errors. When my GUI app is ran from a
> > console window, the exception is thrown in there. But when somethign
> > happens and the console window is not there, I would like to see an
> > error window similar to the stack walker. The way it is now, errors
> > and exceptions are eaten if I rename my app's extension to myapp.pyw
> > ..
> >
> > I would not like that as it leads to undesired behaviour and people
> > not seeing an error and think a particular button does not do anything
> > can cause more harm then showing an error dialog. Also if there is no
> > feedback, not many people will file a report.
> >
> > Is there a way to get errors back from python's exceptions when there
> > is no console window??
> >
> > Regards,
> > - Jorgen
>
> Here is a simple pattern I use for gui apps with wxPython/excepthook:
>
> import sys, traceback, wx
>
> def excepthook(type, value, trace):
> if wx and sys and traceback:
> exc = traceback.format_exception(type, value, trace)
> for e in exc: wx.LogError(e)
> wx.LogError('Unhandled Error: %s: %s'%(str(type), str(value)))
> sys.__excepthook__(type, value, trace)
>
> And in your initialization code:
> sys.excepthook = excepthook
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
More information about the wxpython-users
mailing list