在Helper()方法中,我能否在运行时检测程序执行是否是由于抛出异常而导致的?
注意,我的目标是避免扩展Helper()方法以接受异常对象作为输入参数。
public void MyFunc1()
{
try
{
// some code here that eventaully throws an exception
}
catch( Exception ex )
{
Helper();
}
}
public void MyFunc2()
{
Helper();
}
private void Helper()
{
// how can I check if program execution is the
// result of a thrown exception here.
}
throw new Exception()
对我来说很好用。也许这已经改变了? - porges