I have code resembling the following:
try{
func1();
}
catch(Exception e){
/Do something
}
static func1(){
func2();
}
static func2(){
//Exception thrown here
System.IO.StreamReader file = new System.IO.StreamReader(filePath);
}
when an exception is thrown by the line of code in func2() I get no notification in the catch clause. I do not explicitly throw anything, I just have regular function declarations which are static- no “throw” appears anywhere.
Why isn’t the exception propagating upwards to the catch statement??
An exception will ‘bubble up’ until it is caught or crashes your app.
Your best bet is to use the Debugger. Make sure you have it set to stop on HANDLED exceptions (Debug / Exceptions / Check the ‘Thrown’ box on the Common Language Runtime Exceptions).
Now run your code. If func2 throws an exception – your code will break; regardless of whether or not it is handled. You can step through the code and see what is handling it.