Can I detect at runtime inside method Helper() that the program execution is the result of a thrown exception?
Note, my goal is to avoid extending method Helper()
Not that I'm aware of. This is cumbersome, but it fully delineates you as the developer's intent:
private bool inException = false;
public void MyFunc1()
{
try
{
inException = false;
// some code here that eventaully throws an exception
}
catch( Exception ex )
{
inException = true;
Helper();
}
}
public void MyFunc2()
{
inException = false;
Helper();
}
private void Helper()
{
// how can I check if program execution is the
// result of a thrown exception here.
if (inException)
{
// do things.
}
}