@inherits ErrorBoundary
@inject ISnackbar Snackbar

@if (CurrentException is null)
{
    @ChildContent
}
else if (ErrorContent is not null)
{
    @ErrorContent(CurrentException)
}
else
{
    <div class="custom-error-ui">
        <MudAlert Severity="Severity.Error" Icon="@Icons.Material.Filled.Error">
            <MudText>组件加载或执行时出现了问题。</MudText>
            <MudButton Variant="Variant.Filled"
                       Color="Color.Primary"
                       Class="mt-3">
                重试
            </MudButton>
        </MudAlert>
    </div>
}


@code {
    protected override async Task OnErrorAsync(Exception exception)
    {
        Snackbar.Add("操作失败，请重试或联系管理员。", Severity.Error);

        await base.OnErrorAsync(exception);
    }

}
