This proposes adding an error boundaries feature to Blazor, as inspired by the implementation in React. This feature would allow developers to implement logic on individual components to capture any excpetions, log, display a fallback UI, send telemetry, etc.
This feature was proposed in https://github.com/dotnet/aspnetcore/issues/13452 but I'm pulling it out into a separate issue to avoid conflating per-component exception handling with global exception handling.
A meaningfully complex Blazor app will contain numerous components, both first-party and third-party. There's no way to guarantee that all exception cases will be handled in a component. There's also no way to indicate that even though an unhandled exception occurred in one part of the app, that the entire app is not compromised.
Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
This would be wonderful. At a motivating use case, here’s a situation I can’t currently handle in Blazor:
<div>
<MyComponent />
<ThirdPartyComponent Attr=“null” />
</div>
where ThirdPartyComponent.razor contains something like this:
@code {
[Parameter] public string Attr { get; set; }
}
<p>@Attr.ToLower()</p>
Right now, there’s no way to salvage the render tree and display at least MyComponent, due to the failure to handle errors inside the other Component
Most helpful comment
This would be wonderful. At a motivating use case, here’s a situation I can’t currently handle in Blazor:
where
ThirdPartyComponent.razorcontains something like this:Right now, there’s no way to salvage the render tree and display at least MyComponent, due to the failure to handle errors inside the other Component