32 lines
615 B
Plaintext
32 lines
615 B
Plaintext
@inherits ErrorBoundary
|
|
|
|
|
|
@if (_currentError != null)
|
|
{
|
|
<div class="error-message">
|
|
<p>An error has occurred: @_currentError.Message</p>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
@ChildContent
|
|
}
|
|
|
|
@code {
|
|
private Exception? _currentError;
|
|
|
|
[Parameter]
|
|
public EventCallback<Exception> 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;
|
|
}
|
|
} |