35 lines
662 B
Plaintext
35 lines
662 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;
|
|
if (OnError.HasDelegate)
|
|
{
|
|
return OnError.InvokeAsync(exception);
|
|
}
|
|
return base.OnErrorAsync(exception);
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
_currentError = null;
|
|
}
|
|
} |