From 0d8d816a0c424b1e033af7d4d1331816bbb61426 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 24 Jun 2024 15:24:23 +0700 Subject: [PATCH] Include error message text on page Also remove the '500' h1 from the error Closes #3248 --- .eslintrc.cjs | 2 +- ts/routes/+error.svelte | 11 +++++++++++ ts/src/hooks.client.js | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 ts/routes/+error.svelte create mode 100644 ts/src/hooks.client.js diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3badc3ca3..2c5502f64 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -50,7 +50,7 @@ module.exports = { }, ], env: { browser: true, es2020: true }, - ignorePatterns: ["backend_proto.d.ts", "*.svelte.d.ts", "vendor", "extra/*", "vite.config.ts"], + ignorePatterns: ["backend_proto.d.ts", "*.svelte.d.ts", "vendor", "extra/*", "vite.config.ts", "hooks.client.js"], globals: { globalThis: false, NodeListOf: false, diff --git a/ts/routes/+error.svelte b/ts/routes/+error.svelte new file mode 100644 index 000000000..8f171d33d --- /dev/null +++ b/ts/routes/+error.svelte @@ -0,0 +1,11 @@ + + + +{message} diff --git a/ts/src/hooks.client.js b/ts/src/hooks.client.js new file mode 100644 index 000000000..b6786409b --- /dev/null +++ b/ts/src/hooks.client.js @@ -0,0 +1,8 @@ +/** @type {import('@sveltejs/kit').HandleClientError} */ +export async function handleError({ error, event, status, message }) { + /** @type {any} */ + const anyError = error; + return { + message: anyError.message, + }; +}