| | | 1 | | @using Microsoft.JSInterop |
| | | 2 | | @using Microsoft.Extensions.Logging |
| | | 3 | | |
| | | 4 | | <div class="error-container"> |
| | | 5 | | <div class="error-content"> |
| | 35 | 6 | | <div class="error-icon">@Constants.ErrorDisplay.ErrorIcon</div> |
| | 35 | 7 | | <h3>@Constants.ErrorDisplay.ErrorTitle</h3> |
| | 35 | 8 | | <p class="error-message">@ErrorMessage</p> |
| | | 9 | | <div class="error-actions"> |
| | | 10 | | <button class="btn btn-primary" @onclick="OnRetry"> |
| | 35 | 11 | | @Constants.ErrorDisplay.RetryButtonText |
| | | 12 | | </button> |
| | | 13 | | <button class="btn btn-secondary" @onclick="OnReload"> |
| | 35 | 14 | | @Constants.ErrorDisplay.ReloadButtonText |
| | | 15 | | </button> |
| | | 16 | | </div> |
| | | 17 | | </div> |
| | | 18 | | </div> |
| | | 19 | | |
| | | 20 | | @code { |
| | | 21 | | [Parameter] |
| | 136 | 22 | | public Exception? Exception { get; set; } |
| | | 23 | | |
| | | 24 | | [Parameter] |
| | 61 | 25 | | public EventCallback OnRetry { get; set; } |
| | | 26 | | |
| | | 27 | | [Inject] |
| | 69 | 28 | | private IJSRuntime JSRuntime { get; set; } = default!; |
| | | 29 | | |
| | | 30 | | [Inject] |
| | 101 | 31 | | private ILogger<ErrorDisplay> Logger { get; set; } = default!; |
| | | 32 | | |
| | 35 | 33 | | private string ErrorMessage => Exception?.Message ?? Constants.ErrorDisplay.DefaultErrorMessage; |
| | | 34 | | |
| | | 35 | | protected override void OnParametersSet() |
| | 34 | 36 | | { |
| | 34 | 37 | | if (Exception != null) |
| | 33 | 38 | | { |
| | 33 | 39 | | Logger.LogError(Exception, Constants.Messages.LogErrorCaughtByBoundary); |
| | 33 | 40 | | } |
| | 34 | 41 | | } |
| | | 42 | | |
| | | 43 | | private async Task OnReload() |
| | 1 | 44 | | { |
| | 1 | 45 | | await JSRuntime.InvokeVoidAsync("location.reload"); |
| | 1 | 46 | | } |
| | | 47 | | } |