Open
Description
Update: The actual request here is being able to have the debugger break if there's an unhandled exception. Please disregard the stuff about AppDomain.CurrentDomain.UnhandledException.
Original report
Looks like this is an issue impacting the community: https://www.reddit.com/r/Blazor/comments/vhrrl1/blazor_wasm_how_to_break_on_unhandled_exception/
Ideally we can hook into the System.AppDomain.CurrentDomain.UnhandledException
as we do with WebView for WinForms / WPF.
Repro:
Index.razor
:
<button @onclick="ThrowException">Throw Exception</button>
@code {
public void ThrowException()
{
throw new Exception("throwing new ex");
}
}
Program.cs
:
System.AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
{
System.Console.WriteLine("!!! Encountered exception !!!");
};
Expected: !!! Encountered exception !!!
console output
Actual: The exception breaks the world // stack trace dumps to console
Kind of related: dotnet/maui#5535