Reputation: 455
I found many questions about how to track down where a caught exception is thrown but I can't find any question about where a thrown exception is caught in code. Let's say we work with a huge program and somewhere in code an exception is thrown manually but not caught at the same block or where it was called from. Since the application does not terminate we can assume that the exception is being caught somewhere. How can we track that exception in Visual Studio and see where it is caught and handled?
Upvotes: 1
Views: 85
Reputation: 27880
You can use my Runtime Flow tool for some help.
For example, running the following program:
class Program
{
static void bar()
{
throw new ApplicationException("");
}
static void foo()
{
bar();
}
static void Main(string[] args)
{
try
{
foo();
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Generates the following monitoring result:
You can see how an exception is thrown from the bar method, then from the foo method and not thrown (caught) in Main.
Upvotes: 1