diff --git a/.idea/.idea.Moonlight/.idea/.name b/.idea/.idea.Moonlight/.idea/.name
deleted file mode 100644
index 9d9b9a74..00000000
--- a/.idea/.idea.Moonlight/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-Moonlight
\ No newline at end of file
diff --git a/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor b/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor
index 6f049421..87812157 100644
--- a/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor
+++ b/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor
@@ -12,8 +12,9 @@
@inject AlertService AlertService
@inject ConfigService ConfigService
@inject SmartTranslateService SmartTranslateService
+@inject NavigationManager NavigationManager
-@if (Crashed)
+@if (HardCrashed)
{
}
+else if (SoftCrashed)
+{
+
+
+ @(ErrorMessage)
+
+
+
+ @ChildContent
+}
else
{
@ChildContent
@@ -37,8 +48,23 @@ else
@code
{
- private bool Crashed = false;
-
+ private bool HardCrashed = false;
+ private bool SoftCrashed = false;
+ private string ErrorMessage = "";
+
+ protected override void OnInitialized()
+ {
+ NavigationManager.LocationChanged += OnPathChanged;
+ }
+
+ private void OnPathChanged(object? sender, LocationChangedEventArgs e)
+ {
+ if (SoftCrashed)
+ SoftCrashed = false;
+
+ StateHasChanged();
+ }
+
protected override async Task OnErrorAsync(Exception exception)
{
if (ConfigService.DebugMode)
@@ -50,74 +76,57 @@ else
{
if (displayException.DoNotTranslate)
{
- await AlertService.Error(
- displayException.Message
- );
+ await SoftCrash(displayException.Message);
}
else
{
- await AlertService.Error(
- SmartTranslateService.Translate(displayException.Message)
- );
+ await SoftCrash(SmartTranslateService.Translate(displayException.Message));
}
}
else if (exception is CloudflareException cloudflareException)
{
- await AlertService.Error(
- SmartTranslateService.Translate("Error from cloudflare api"),
- cloudflareException.Message
- );
+ await SoftCrash(SmartTranslateService.Translate("Error from cloudflare: ") + cloudflareException.Message);
}
else if (exception is WingsException wingsException)
{
- await AlertService.Error(
- SmartTranslateService.Translate("Error from wings"),
- wingsException.Message
- );
-
- //TODO: Error log service
+ await SoftCrash(SmartTranslateService.Translate("Error from wings: ") + wingsException.Message);
Logger.Warn($"Wings exception status code: {wingsException.StatusCode}");
}
else if (exception is DaemonException daemonException)
{
- await AlertService.Error(
- SmartTranslateService.Translate("Error from daemon"),
- daemonException.Message
- );
+ await SoftCrash(SmartTranslateService.Translate("Error from daemon: ") + daemonException.Message);
Logger.Warn($"Wings exception status code: {daemonException.StatusCode}");
}
else if (exception is ModrinthException modrinthException)
{
- await AlertService.Error(
- SmartTranslateService.Translate("Error from modrinth"),
- modrinthException.Message
- );
+ await SoftCrash(SmartTranslateService.Translate("Error from modrinth: ") + modrinthException.Message);
}
else if (exception is CloudPanelException cloudPanelException)
{
- await AlertService.Error(
- SmartTranslateService.Translate("Error from cloud panel"),
- cloudPanelException.Message
- );
+ await SoftCrash(SmartTranslateService.Translate("Error from cloudpanel: ") + cloudPanelException.Message);
}
else if (exception is NotImplementedException)
{
- await AlertService.Error(SmartTranslateService.Translate("This function is not implemented"));
+ await SoftCrash(SmartTranslateService.Translate("This function is not implemented"));
}
else if (exception is StripeException stripeException)
{
- await AlertService.Error(
- SmartTranslateService.Translate("Unknown error from stripe"),
- stripeException.Message
- );
+ await SoftCrash(SmartTranslateService.Translate("Error from stripe: ") + stripeException.Message);
}
else
{
Logger.Warn(exception);
- Crashed = true;
+ HardCrashed = true;
await InvokeAsync(StateHasChanged);
}
}
+
+ private Task SoftCrash(string message)
+ {
+ SoftCrashed = true;
+ ErrorMessage = message;
+ return Task.CompletedTask;
+ }
}
\ No newline at end of file