let's say methodA and methodB will both throw a couple of types of exceptions, and some exceptions are of the same type, some are not, so what's the best practice to handle this?
style A:
void foo()
{
try
{
methodA();
}
catch (exceptionTypeA)
{
handleA;
}
try
{
methodB();
}
catch (exceptionB)
{
handleB;
}
}
style B:
void foo()
{
try
{
methodA();
methodB();
}
catch (exceptionTypeA)
{
handleA;
}
catch (exceptionB)
{
handleB;
}
}