We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cover ...
@context
Recover
Context={CONTEXT}
OnErrorAsync
@context with recovery example ...
<ErrorBoundary @ref="errorBoundary"> <ChildContent> <EmbeddedCounter /> </ChildContent> <ErrorContent> <div class="alert alert-danger" role="alert"> <p class="fs-3 fw-bold">😈 A rotten gremlin got us. Sorry!</p> <p>@context.GetType(): @context.Message</p> <button class="btn btn-info" @onclick="_ => errorBoundary.Recover()">Clear</button> </div> </ErrorContent> </ErrorBoundary> @code { private ErrorBoundary? errorBoundary; }
Custom context ...
<ErrorContent Context="exception"> @exception.Message </ErrorContent>
Subclassed CustomErrorBoundary component (CustomErrorBoundary.razor) for custom processing with OnErrorAsync ...
CustomErrorBoundary
CustomErrorBoundary.razor
@inherits ErrorBoundary @inject ILogger<CustomErrorBoundary>? Logger @if (CurrentException is null) { @ChildContent } else if (ErrorContent is not null) { @ErrorContent(CurrentException) } @code { protected override async Task OnErrorAsync(Exception exception) { await Task.Yield(); Logger?.LogError("{Type}: {Message}", exception.GetType(), exception.Message); } }
OR ... preceding component implemented in code ...
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; namespace BlazorSample; public class CustomErrorBoundary : ErrorBoundary { [Inject] ILogger<CustomErrorBoundary>? Logger { get; set; } protected override async Task OnErrorAsync(Exception exception) { await Task.Yield(); Logger?.LogError("{Type}: {Message}", exception.GetType(), exception.Message); } }
Used as ...
<CustomErrorBoundary> ... </CustomErrorBoundary>
Cross-references:
<xref:Microsoft.AspNetCore.Components.ErrorBoundaryBase.OnErrorAsync%2A>
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/handle-errors?view=aspnetcore-8.0
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/fundamentals/handle-errors.md
66a0b1c2-c45c-98ca-9808-6f340a861c44
@guardrex
The text was updated successfully, but these errors were encountered:
guardrex
Successfully merging a pull request may close this issue.
Uh oh!
There was an error while loading. Please reload this page.
Description
Cover ...
@context
).Recover
).Context={CONTEXT}
).OnErrorAsync
).@context
with recovery example ...Custom context ...
Subclassed
CustomErrorBoundary
component (CustomErrorBoundary.razor
) for custom processing withOnErrorAsync
...OR ... preceding component implemented in code ...
Used as ...
Cross-references:
<xref:Microsoft.AspNetCore.Components.ErrorBoundaryBase.OnErrorAsync%2A>
Page URL
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/handle-errors?view=aspnetcore-8.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/fundamentals/handle-errors.md
Document ID
66a0b1c2-c45c-98ca-9808-6f340a861c44
Article author
@guardrex
The text was updated successfully, but these errors were encountered: