dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.51k stars 10.04k forks source link

Application.DispatcherUnhandledException alternative in Blazor #43454

Closed Skintkingle closed 11 months ago

Skintkingle commented 2 years ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

When we make a call to a service from blazor web assembly the server may error and return a http status code of 500 along with a correlation id. The error is treated as unhandled and propagates up through the components. We can customise the blazor-error-ui message but only at design time and therefore we cannot modify this to display the correlation id.

This is one example of when we would like to be able to interpret the exception that occurred and display a message based on that exception. Another example would be if the error message contains a user friendly message that should be displayed.

The issue https://github.com/dotnet/aspnetcore/issues/24108 mentions adding more detail to the message but doesn't offer developer customisation.

We have tried using the ErrorBoundary wrapping the application in App.razor but having the entire application disappear and be replaced with an error dialog isn't a good user experience. We have also tried to create a custom component from ErrorBoundaryBase that displays our own error content but sets ShouldRender to false so the client application remains. However, this results in all content being removed and leaving a blank browser window and was feeling very 'hacky'.

Describe the solution you'd like

We would like to have an extension point that allows us to interpret the exception being raised and change the UI rendered by blazor-error-ui based on the content of that exception. This extension could be javascript only or it could be an adaptation of the ErrorBoundary?

For example the showErrorNotification function could take the error exception and call an extensible point we provide? In addition if our extension "handles" the error and returns true that would suppress the blazor-error-ui being shown.

Ultimately we are looking for a similar experience to the Application.DispatcherUnhandledException event in WPF.

Additional context

This is a re-raise of this previous feature request that was treated as a "Question" and then left unaddressed so your bot came along and closed it. As per the "Issue management policy" the advice is to re-raise. Given the responses by both myself and Philip were left unaddressed I would like to re-emphasize our responses on that related request and seek further clarifications (or actually have a feature request raised for this)

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

mkArtakMSFT commented 11 months ago

Thanks for contacting us. While this may be a great idea, it is not aligned with our long-term vision to make it part of the framework. For many other ideas which don't belong to the framework we encourage the community to build and ship on their own, contributing to the expanding .NET Ecosystem.

You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.