Skip to content

Break on first-chance exception in Web Assembly debugger #42510

Open
@TanayParikh

Description

@TanayParikh

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions