I would like to be able to catch all unhandled exceptions in one single place building a Blazor single page application. Like using the "Current.DispatcherUnhandledException" in WPF applications.
This question is exclusively about client-side (webassembly) exception handling. I am using Blazor version 3.0.0-preview8.19405.7
I have been searching for a solution, but it seems like it does not exist. On Microsofts documentation (https://learn.microsoft.com/en-us/aspnet/core/blazor/handle-errors?view=aspnetcore-3.0) there is a list of places errors may occur and a walk through on how to handle each one of them. It believe there must be a more bullet proof way to catch all.
Currently there is no central place to catch and handle client side exceptions.
Here is a quote from Steve Sanderson about it:
So overall, each component must deal with handling its own errors. If you want, you could make your own ErrorHandlingComponentBase to inherit from, and put a try/catch around all the lifecycle methods, and have your own logic for displaying an "oh dear sorry I died" UI on that component if anything went wrong. But it's not a feature of the framework today.
I hope this will change in the future and I believe support should be backed into the framework.