Will the exception be returned to the calling method?

Let's say one way, I

try { callme(); } catch { // handle callme exception } 

Now let say callme () call method1 (), which in turn calls method2 () - If method2 () throws an exception, if it returns to the method1 () frame, which then stops any subsequent execution within itself and passes the exception thrown from method2 () to the callme () frame and back to the original stack frame?

Will this happen if I go through the code? Or will VS2008 stop as soon as it sees an exception if it is not handled in the original method?

I throw an exception, but then the debugger complains:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it occurred in the code.

as soon as I click on the closing bracket of method2 ().

I'm a little confused, I thought the exceptions should have been returned in full.

+4
source share
1 answer

At run time, the exception will call the call stack until one of the following events occurs:

  • He ends up in the catch block.
  • It is caught by the global exception handler.
  • It does not fall into the user code and a general exception message is displayed.

When debugging, the situation is slightly different, because the debugger can be configured to break unhandled user exceptions. This may be what happens in your case. Check the Debug / Exclusions option in Visual Studio to make sure your debugger is configured to detect any unhandled exceptions before it bubbles up and exits user code.

+10
source

All Articles