As for "why", well some would call it lazy, and some would call it efficient! But, basically, in my web layer, around almost all my top-level methods (event handlers, onload, oninit etc), I have the same code over and over:
try
{
...
}
catch (Exception ex)
{
App.PageManager.HandleException(ex);
}
It would be nice to be able to instead just add an attribute (say "[DefaultExceptionHandling"]) to these methods for two reasons:
- less code to write
- It would be possible to change the default exception handling in one place, and have it apply everywhere.
This is kind of getting into "aspect oriented programming" / "Code Injection" area, which i have heard a little about, but do not have any experience in.
If anyone has any info on how i could achieve the above, it would be much appreciated.
Thanks
P.S. And before anyone says it, no i don't want to just handle the error in the OnError event. This stops the rest of the page processing - which i do not want to do... and besides, i know want to know how to "wrap" code! 