I was thinking that is it possible to do exception handling using Attribute, rather than write "try...catch" in every single method.
for example, now, each of my method look like this:
public void DoSomething()
{
try
{
// do something
}
catch (Exception ex)
{
// exception handling rules, always the same.
throw;
}
}
I want:
[HandleException]
public void DoSomething()
{
// do something
}
Is it possible?
This can be done via AOP (aspect oriented programming). One of the frameworks for doing so is PostSharp. See a sample http://www.sharpcrafters.com/solutions/exception
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With