@using salesbook.Shared.Core.Services
@inject AppAuthenticationStateProvider AuthenticationStateProvider
@if (Exception != null)
{
@Message
}
@code {
[Parameter] public Exception? Exception { get; set; }
[Parameter] public EventCallback OnRetry { get; set; }
[Parameter] public ErrorBoundary? ErrorBoundary { get; set; }
private string Message { get; set; } = "";
protected override void OnInitialized()
{
if (Exception == null) return;
if (Exception.Message.Contains("Failed to connect to"))
{
var ipPort = Exception.Message.Split("to /")[1];
Message = $"Impossibile collegarsi al server ({ipPort})";
}
else
{
Message = Exception.Message;
}
StateHasChanged();
}
private async Task OnRetryClick()
{
await OnRetry.InvokeAsync();
}
private async Task OnContinueClick()
{
NavigationManager.NavigateTo("/");
await OnRetry.InvokeAsync();
}
}