diff --git a/frontend/src/errorPage.html b/frontend/src/errorPage.html
new file mode 100644
index 0000000..7c3e876
--- /dev/null
+++ b/frontend/src/errorPage.html
@@ -0,0 +1,10 @@
+
+
+
An Error Has Occured
+
+
+
+
+
diff --git a/frontend/src/routing.ts b/frontend/src/routing.ts
index b998314..c4ae5b2 100644
--- a/frontend/src/routing.ts
+++ b/frontend/src/routing.ts
@@ -1,5 +1,6 @@
import { updateUser } from "@app/auth";
import { ensureWindowState, escapeHTML } from "@app/utils";
+import errorPage from "./errorPage.html?raw";
ensureWindowState();
@@ -14,7 +15,8 @@ declare module "ft_state" {
window.__state.routes ??= new Map();
window.__state.title ??= "";
-window.__state.titleElem ??= document.querySelector("#header-title")!;
+window.__state.titleElem ??=
+ document.querySelector("#header-title")!;
window.__state._routingHandler ??= false;
// ---- Router logic ----
@@ -206,18 +208,26 @@ export async function handleRoute() {
);
const app = document.getElementById("app")!;
- const event = new CustomEvent("ft:pageChange", { detail: window.location.pathname });
+ const event = new CustomEvent("ft:pageChange", {
+ detail: window.location.pathname,
+ });
document.dispatchEvent(event);
- let ret = await executeRouteHandler(
- route_handler,
- window.location.pathname,
- args,
- );
- app.innerHTML = ret.html;
- if (ret.postInsert) {
- let r = ret.postInsert(app);
- if (r instanceof Promise) await r;
+ try {
+ let ret = await executeRouteHandler(
+ route_handler,
+ window.location.pathname,
+ args,
+ );
+ app.innerHTML = ret.html;
+ if (ret.postInsert) {
+ let r = ret.postInsert(app);
+ if (r instanceof Promise) await r;
+ }
+ } catch (e: any) {
+ app.innerHTML = errorPage;
+ let err = app.querySelector("#error-msg");
+ if (err) err.innerHTML = e.toString();
}
}