.net Attributes that handle exceptions - usage on a property accessor
- by Mr AH
Hi, well I know from my asp.net mvc experience that you can have attributes that handle exceptions (HandleErrorAttribute). As far as I can tell the Controller class has some OnException event which may be integral to this behaviour. However, I want to do something similar in my own code:
dream example:
public String MyProperty
{
[ExceptionBehaviour(typeof(FormatException), MyExEnum.ClearValue)]
set
{
_thing.prop = Convert.ToThing(value);
}
}
....
The code above obviously makes very little sense, but is close to the kind of thing I wish to do. I want the attribute on the property set accessor to catch some type of exception and then deal with this in some custom way (or even just swallow it).
Any ideas guys?