Merge pull request #56 from Moonlight-Panel/NewSoftErrorBoundaryCrashHandler
Implemented new soft error boundary crash handler
This commit is contained in:
commit
fdacc60ad4
|
@ -7,13 +7,35 @@
|
||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
@ChildContent
|
@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
|
@code
|
||||||
{
|
{
|
||||||
|
private bool Crashed = false;
|
||||||
|
|
||||||
protected override async Task OnErrorAsync(Exception exception)
|
protected override async Task OnErrorAsync(Exception exception)
|
||||||
{
|
{
|
||||||
Logger.Debug(exception);
|
Logger.Warn(exception);
|
||||||
|
|
||||||
if (exception is DisplayException displayException)
|
if (exception is DisplayException displayException)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +71,8 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw exception;
|
Crashed = true;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -59,57 +59,55 @@
|
||||||
<div id="kt_app_content" class="app-content flex-column-fluid">
|
<div id="kt_app_content" class="app-content flex-column-fluid">
|
||||||
<div id="kt_app_content_container" class="app-container container-fluid">
|
<div id="kt_app_content_container" class="app-container container-fluid">
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
<PageErrorBoundary>
|
<SoftErrorBoundary>
|
||||||
<SoftErrorBoundary>
|
@if (uri.LocalPath != "/login" &&
|
||||||
@if (uri.LocalPath != "/login" &&
|
uri.LocalPath != "/passwordreset" &&
|
||||||
uri.LocalPath != "/passwordreset" &&
|
uri.LocalPath != "/register")
|
||||||
uri.LocalPath != "/register")
|
{
|
||||||
|
if (User == null)
|
||||||
{
|
{
|
||||||
if (User == null)
|
<Login></Login>
|
||||||
{
|
|
||||||
<Login></Login>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (User.Status == UserStatus.Banned)
|
|
||||||
{
|
|
||||||
<BannedAlert></BannedAlert>
|
|
||||||
}
|
|
||||||
else if (User.Status == UserStatus.Disabled)
|
|
||||||
{
|
|
||||||
<DisabledAlert></DisabledAlert>
|
|
||||||
}
|
|
||||||
else if (User.Status == UserStatus.PasswordPending)
|
|
||||||
{
|
|
||||||
<PasswordChangeView></PasswordChangeView>
|
|
||||||
}
|
|
||||||
else if (User.Status == UserStatus.DataPending)
|
|
||||||
{
|
|
||||||
<UserDataSetView></UserDataSetView>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@Body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (uri.LocalPath == "/login")
|
if (User.Status == UserStatus.Banned)
|
||||||
{
|
{
|
||||||
<Login></Login>
|
<BannedAlert></BannedAlert>
|
||||||
}
|
}
|
||||||
else if (uri.LocalPath == "/register")
|
else if (User.Status == UserStatus.Disabled)
|
||||||
{
|
{
|
||||||
<Register></Register>
|
<DisabledAlert></DisabledAlert>
|
||||||
}
|
}
|
||||||
else if (uri.LocalPath == "/passwordreset")
|
else if (User.Status == UserStatus.PasswordPending)
|
||||||
{
|
{
|
||||||
<PasswordReset></PasswordReset>
|
<PasswordChangeView></PasswordChangeView>
|
||||||
|
}
|
||||||
|
else if (User.Status == UserStatus.DataPending)
|
||||||
|
{
|
||||||
|
<UserDataSetView></UserDataSetView>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@Body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</SoftErrorBoundary>
|
}
|
||||||
</PageErrorBoundary>
|
else
|
||||||
|
{
|
||||||
|
if (uri.LocalPath == "/login")
|
||||||
|
{
|
||||||
|
<Login></Login>
|
||||||
|
}
|
||||||
|
else if (uri.LocalPath == "/register")
|
||||||
|
{
|
||||||
|
<Register></Register>
|
||||||
|
}
|
||||||
|
else if (uri.LocalPath == "/passwordreset")
|
||||||
|
{
|
||||||
|
<PasswordReset></PasswordReset>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</SoftErrorBoundary>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -161,8 +159,8 @@
|
||||||
await JsRuntime.InvokeVoidAsync("document.body.removeAttribute", "data-kt-app-page-loading");
|
await JsRuntime.InvokeVoidAsync("document.body.removeAttribute", "data-kt-app-page-loading");
|
||||||
await JsRuntime.InvokeVoidAsync("KTMenu.createInstances");
|
await JsRuntime.InvokeVoidAsync("KTMenu.createInstances");
|
||||||
await JsRuntime.InvokeVoidAsync("KTDrawer.createInstances");
|
await JsRuntime.InvokeVoidAsync("KTDrawer.createInstances");
|
||||||
|
|
||||||
//await JsRuntime.InvokeVoidAsync("createSnow");
|
//await JsRuntime.InvokeVoidAsync("createSnow");
|
||||||
|
|
||||||
await SessionService.Register();
|
await SessionService.Register();
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,12 @@
|
||||||
@page "/test"
|
@page "/test"
|
||||||
@using Moonlight.App.Repositories
|
|
||||||
@using Moonlight.App.Database.Entities
|
|
||||||
@using Moonlight.App.Models.Forms
|
|
||||||
|
|
||||||
@inject UserRepository UserRepository
|
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
|
|
||||||
<div class="mb-3">
|
|
||||||
<SmartDropdown
|
|
||||||
Items="Users"
|
|
||||||
@bind-Value="Model.User"
|
|
||||||
DisplayFunc="@(x => x.Email)"
|
|
||||||
SearchProp="@(x => x.Email)" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button class="btn btn-primary" type="submit">Submit</button>
|
|
||||||
</div>
|
|
||||||
</SmartForm>
|
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
private User[] Users;
|
|
||||||
private TestDataModel Model = new();
|
|
||||||
|
|
||||||
private Task Load(LazyLoader arg)
|
private Task Load(LazyLoader arg)
|
||||||
{
|
{
|
||||||
Users = UserRepository.Get().ToArray();
|
throw new Exception("Nein");
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task OnValidSubmit()
|
|
||||||
{
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue