BPT

Error

The BptError system intercepts render exceptions and HTTP errors before they crash the Blazor circuit, displaying branded error templates with Development/Production modes and context-sensitive recovery actions.

Error Parameters
Trigger Errors

Click a button to simulate an error and see the corresponding template:

Quick HTTP codes:

Click a trigger button above to preview an error template.

Current Configuration
📋 [+]
<!-- Error handling is enabled on BptRootComponent -->
<BptRootComponent EnableErrorHandling="true">
    @Body
</BptRootComponent>

<!-- Errors are caught automatically. To trigger manually: -->
@code {
    [CascadingParameter]
    public BptErrorState? ErrorState { get; set; }

    void ShowError() => ErrorState?.ShowHttpError(404);
}

@code {
// Display mode: Development
// Current preview: None

// Enable error handling in BaseLayout.razor:
<BptRootComponent EnableErrorHandling="true"
                  IsDevelopment="true"
                  OnError="HandleError">
    @Body
</BptRootComponent>

// Handle errors with a callback:
private async Task HandleError(BptErrorEventArgs args)
{
    await _logger.LogAsync(args.ErrorContext);
    // args.Handled = true; // Suppress BptError UI
}

// Register HttpClient error interception:
builder.Services.AddScoped<BptErrorState>();
builder.Services.AddScoped<BptHttpErrorHandler>();
builder.Services.AddHttpClient("API")
    .AddHttpMessageHandler<BptHttpErrorHandler>();
}
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.