Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can code in a "try...catch" block throw an unhandled exception?

I had an exception in some code today: "A [some exception] was unhandled."

However, this code was clearly inside the "try" block of a "try/catch" structure.

What am I missing here?

Update: It's C#

Update: Oh, forget it. It turns out the specific mechanism of error is that I'm an idiot. There's no fix for this.

like image 576
Deane Avatar asked Nov 17 '09 16:11

Deane


People also ask

Can you throw an exception in a catch block?

A throw statement can be used in a catch block to re-throw the exception that is caught by the catch statement. The following example extracts source information from an IOException exception, and then throws the exception to the parent method. You can catch one exception and throw a different exception.

What happens when you throw an error in a catch block?

One related and confusing thing to know is that in a try-[catch]-finally structure, a finally block may throw an exception and if so, any exception thrown by the try or catch block is lost.

How do you find the unhandled exception?

If your application has unhandled exceptions, that may be logged in the Windows Event Viewer under the category of “Application”. This can be helpful if you can't figure out why your application suddenly crashes. Windows Event Viewer may log 2 different entries for the same exception.

What happens to an unhandled exception in a method?

An unhandled exception is an exception that does not have an associated handler. In C++ any unhandled exception terminates the program. It is unspecified whether the stack is unwound in this case, i.e. destructors of successfully constructed local variables may be executed or not depending on the compiler.


1 Answers

Does the catch statement specify a specific type of exception?

If it does, it will only catch that type of exception.

like image 70
Kevin Laity Avatar answered Oct 21 '22 08:10

Kevin Laity