From 149db6db91af804af45080edd58719bb1db5199d Mon Sep 17 00:00:00 2001
From: Simon <63975668+Simyon264@users.noreply.github.com>
Date: Fri, 23 Aug 2024 23:43:16 +0200
Subject: [PATCH] Add error pages
---
ReplayBrowser/Pages/Shared/Layout/Error.razor | 5 ++
.../Pages/Shared/Layout/ErrorCode.razor | 75 +++++++++++++++++++
.../Pages/Shared/Layout/Routes.razor | 2 +-
ReplayBrowser/Pages/ViewReplay.razor | 8 +-
ReplayBrowser/Startup.cs | 1 +
5 files changed, 89 insertions(+), 2 deletions(-)
create mode 100644 ReplayBrowser/Pages/Shared/Layout/ErrorCode.razor
diff --git a/ReplayBrowser/Pages/Shared/Layout/Error.razor b/ReplayBrowser/Pages/Shared/Layout/Error.razor
index 59631b4..f25f1b5 100644
--- a/ReplayBrowser/Pages/Shared/Layout/Error.razor
+++ b/ReplayBrowser/Pages/Shared/Layout/Error.razor
@@ -4,6 +4,11 @@
Oops. The page at doesn't exist. What a shame.
+ Should there be a page here? Contribute to the project on GitHub! + break; + case 500: +There was an error on the server. Please try again later.
+ How did you get here? The other error page *should* have caught this. + break; + default: +There was an error. Please try again later.
+ That's all we know. + break; + } + } +Replay not found
+Loading...
} else { @@ -70,5 +71,10 @@ else { var authstate = await AuthenticationStateProvider.GetAuthenticationStateAsync(); Replay = await ReplayHelper.GetReplay(Id, authstate)!; + if (Replay == null) + { + var currentUrl = Uri.EscapeDataString(NavigationManager.Uri); + NavigationManager.NavigateTo($"/error/404?url={currentUrl}"); + } } } \ No newline at end of file diff --git a/ReplayBrowser/Startup.cs b/ReplayBrowser/Startup.cs index 8bdb137..dfd4f57 100644 --- a/ReplayBrowser/Startup.cs +++ b/ReplayBrowser/Startup.cs @@ -239,6 +239,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) #else app.UseDeveloperExceptionPage(); #endif + app.UseStatusCodePagesWithReExecute("/error/{0}"); app.UseHttpsRedirection();