@inherits ErrorBoundary
@if (_currentError != null)
{
An error has occurred: @_currentError.Message
}
else
{
@ChildContent
}
@code {
private Exception? _currentError;
[Parameter]
public EventCallback OnError { get; set; }
protected override Task OnErrorAsync(Exception exception)
{
_currentError = exception;
return OnError.HasDelegate ? OnError.InvokeAsync(exception) : base.OnErrorAsync(exception);
}
protected override void OnParametersSet()
{
_currentError = null;
}
}