Skip to content

Add support for error boundaries in Blazor #26953

Closed
@captainsafia

Description

@captainsafia

Summary

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 #13452 but I'm pulling it out into a separate issue to be more precise about the proposed solution.

Motivation

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.

Goals

  • Allow users to provide fallback UIs for select component subtrees in the event that there is an exception there
  • Allow users to build apps with cleaner fallback experiences in the event of unexpected UIs
  • Give users more fine-grained control over how failures are handled in the app

Non-goals

  • Implement any kind of global exception handling in Blazor (we already have ILogger for logging, and beyond that, truly unhandled exceptions mean the app is in an undefined state which is unsafe to continue)
  • Add more sophisticated exception handling to the components in Blazor (besides the APIs needed to build this feature)

Metadata

Metadata

Labels

DoneThis issue has been fixedPriority:2Work that is important, but not critical for the releaseUser StoryA single user-facing feature. Can be grouped under an epic.affected-mediumThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneseverity-blockingThis label is used by an internal tool

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions