Reputation: 1232
In a call stack which contains several await statements, when an exception is thrown, the debugger keeps showing the error at each await statement. I was wondering if there's a way to have the debugger only show the initial place where the exception is thrown, but not stop at ever await.
Upvotes: 2
Views: 288
Reputation:
How about System.Diagnostics.DebuggerHidden
attribute? This attribute is used to hide a method or property from the debugger which also prevent debugger from intercepting exception.
[System.Diagnostics.DebuggerHidden]
private static void SecretRun(IEnumerable<int> ints)
{
foreach (var i in ints)
{
try
{
if (i < 50) Console.WriteLine("next" + i);
else throw new Exception("some exception");
}
catch
{
// Ignored
}
}
}
Cons: You will not be able to debug into a method tagged with DebuggerHidden
attribute.
In order to use this attribute, you need to check "Enable Just My Code" at Tools > Options > Debugging > General
Upvotes: 2
Reputation: 118
I'm not sure if there is a setting for what you've mentioned. But if there is a specific error that you are trying to catch/debug then you can change your exception settings (ctrl + alt + E) and tick "Common Language Runtime Exceptions". This will break on the initial error. Then just right click, restore defaults when you're done.
Upvotes: 0