Files
Moonlight/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor
Marcel Baumgartner ca64184faf Revert "Merge pull request #106 from Moonlight-Panel/DiscordBot"
This reverts commit f71fcc0f5d, reversing
changes made to e0bea9b61c.
2023-04-29 23:37:03 +02:00

83 lines
2.6 KiB
Plaintext

@using Moonlight.App.Services.Interop
@using Moonlight.App.Exceptions
@using Moonlight.App.Services
@using Logging.Net
@using Moonlight.App.ApiClients.CloudPanel
@inherits ErrorBoundaryBase
@inject AlertService AlertService
@inject SmartTranslateService SmartTranslateService
@if (Crashed)
{
<div class="card card-flush h-md-100">
<div class="card-body d-flex flex-column justify-content-between mt-9 bgi-no-repeat bgi-size-cover bgi-position-x-center pb-0">
<div class="mb-10">
<div class="fs-2hx fw-bold text-gray-800 text-center mb-13">
<span class="me-2">
<TL>Ooops. This page is crashed</TL>
</span>
</div>
<div class="text-center">
<TL>This page is crashed. The error has been reported to the moonlight team. Meanwhile you can try reloading the page</TL>
</div>
</div>
</div>
</div>
}
else
{
@ChildContent
}
@code
{
private bool Crashed = false;
protected override async Task OnErrorAsync(Exception exception)
{
Logger.Warn(exception);
if (exception is DisplayException displayException)
{
await AlertService.Error(
SmartTranslateService.Translate("Error"),
SmartTranslateService.Translate(displayException.Message)
);
}
else if (exception is CloudflareException cloudflareException)
{
await AlertService.Error(
SmartTranslateService.Translate("Error from cloudflare api"),
cloudflareException.Message
);
}
else if (exception is WingsException wingsException)
{
await AlertService.Error(
SmartTranslateService.Translate("Error from daemon"),
wingsException.Message
);
//TODO: Error log service
Logger.Warn($"Wings exception status code: {wingsException.StatusCode}");
}
else if (exception is CloudPanelException cloudPanelException)
{
await AlertService.Error(
SmartTranslateService.Translate("Error from cloud panel"),
cloudPanelException.Message
);
}
else if (exception is NotImplementedException)
{
await AlertService.Error(SmartTranslateService.Translate("This function is not implemented"));
}
else
{
Crashed = true;
await InvokeAsync(StateHasChanged);
}
}
}