Hi Sebastjan,

this can be solved quite elegantly by combining generic functions[1].

For your case, before() combinator should do nicely:

   from turbogears.errorhandling import dispatch_error, default

   ...

   @dispatch_error.before(default)
   def _notify_on_error(controller, tg_source, tg_errors, tg_exceptions, 
*args, **kw):
       # send email ...

However, this function will get called for both validation errors and 
exceptions. If such behaviour is not desired, one can of course 
specialise before(). For instance:

   @dispatch_error.before("tg_exceptions is not None")

will be applied only when handling an exception.


Cheers,
Simon

[1] http://peak.telecommunity.com/DevCenter/CombiningResults


Sebastjan Trepca wrote:
> Hi guys,
> 
> I would like to get an email every time an error happens in my
> application. Which would be the best approach for this?
> Is there a setting for this or maybe somekind of global exception
> catcher where I could add my handler?
> 
> Thanks, Sebastjan
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to