如果我有这样的东西怎么办:
public static void DoSomething()
{
try
{
//some code
try
{
//some other code
}
catch (Exception e)
{
log.Error("At the end something is wrong: " + e);
FunctionA(); //same function as in the first exception
}
}
catch (Exception e)
{
log.Error("At the start something wrong: " + e);
FunctionA();
}
}
所以我有一个尝试抓住另一个。异常应该是不同的,我想用不同的记录器来处理它们。但是假设我想为这两个异常调用相同的函数。我必须写FunctionA()
2次。这可以吗?或者这种类型的异常还有其他问题吗?建议?