From eb3461d8649f6d6368b35d046a6a96bad9e5ede0 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 16 Feb 2023 18:39:15 -0500 Subject: [PATCH] [+] 404 Page --- src/App.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index ccafc6b..78ce560 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,7 @@ import urlJoin from 'url-join'; import mime from 'mime'; import moment from 'moment'; -import { createResource, createSignal, For, Show } from 'solid-js'; +import {createResource, createSignal, ErrorBoundary, For, Show} from 'solid-js'; import tippy from 'tippy.js'; import 'tippy.js/dist/tippy.css'; @@ -33,7 +33,12 @@ let fullPath = window.location.pathname let filePath = fullPath.startsWith(deployPath) ? fullPath.substring(deployPath.length) : fullPath if (!filePath.startsWith('/')) filePath = `/${filePath}` -const fetchApi = async () => await (await fetch(urlJoin(host, filePath))).json() as File[] +const fetchApi = async () => +{ + const req = await fetch(urlJoin(host, filePath)) + if (req.status == 404) throw "404" + return await req.json() as File[] +} function getIcon(f: File) { @@ -143,6 +148,9 @@ export default function App() { {/*{api.loading && "Loading..."}*/} {/* Files */} +
+ {e == "404" ? "404: Not found" : `Error: ${e}`} +
}>
{/* For each file */} @@ -170,6 +178,7 @@ export default function App() { }
+
);