Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

Why can't you step thru a re-thrown exception ?

$
0
0

I am hoping someone can explain this to me. Why is it impossible to step over/thru a re-thrown exception ? I also do not understand this is flagged as an unhandled exception. I would think unhandled would be no error handling code at all. But if you have code in a try/catch block and in the catch block you simply re-throw the error using "throw;" the debugger just gets stuck there. If you try to step, it just tells you that is unhandled again.

Here is my scenario: I have a class library that has some common calls we use in it. Things like connecting to a database and firing off a stored proc, etc. That database code is wrapped in a try/catch block. In the catch block, I just want to re-throw the SqlException and let the application using the DLL handle the exception. This works fine with the compiled code but if you try to debug an issue, you cannot step thru this class library method because visual gets stuck on the "throw;" line of code.

Why does it do this ? I know there are options to turn off breaking on unhandled user exception but I don't want it off. I want it to do exactly what it is doing but I also want to be able to debug the code too after it breaks ! Am I doing something wrong or misunderstanding something here ? It's really frustrating. Any insight would be appreciated.

screenshot throwing "ex":

 Screenshot using just "throw"

(same result - stuck):


Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>