Working with .NET framework I have a service with a set of methods that can generates several types of exceptions: MyException2, MyExc1, Exception... To provide proper work for all methods, each of them contains following sections:
[WebMethod]
void Method1(...)
{
try
{
... required functionality
}
catch(MyException2 exc)
{
... process exception of MyException2 type
}
catch(MyExc1 exc)
{
... process exception of MyExc1 type
}
catch(Exception exc)
{
... process exception of Exception type
}
... process and return result if necessary
}
It is very boring to have exactly same stuff in EACH service method (each method has different set of parameters) with exactly same exceptions processing functionality...
Is there any possibility to "group" these catch-sections and use only one line (something similar to C++ macros)? Probably something new in .NET 4.0 is related to this topic?
Thanks.
P.S. Any thoughts are welcome.