Add SHD themed error handling

This commit is contained in:
JB
2026-07-25 18:52:39 -04:00
parent 92cda8a576
commit e0bf3b05ab
6 changed files with 97 additions and 2 deletions
+11 -1
View File
@@ -1,4 +1,5 @@
import { json, type Handle } from '@sveltejs/kit';
import { json, type Handle, type HandleServerError } from '@sveltejs/kit';
import { randomUUID } from 'node:crypto';
import { getSessionUser } from '$lib/server/auth/session';
import { DATA_MODULES, queueDataProposal, shouldModerateDataMutation, type DataModule } from '$lib/server/data-moderation';
@@ -30,3 +31,12 @@ export const handle: Handle = async ({ event, resolve }) => {
}
return resolve(event);
};
export const handleError: HandleServerError = ({ error, event, status, message }) => {
const errorId = randomUUID().slice(0, 8).toUpperCase();
console.error(`[${errorId}] ${event.request.method} ${event.url.pathname} -> ${status}`, error);
return {
message: status >= 500 ? 'An unexpected fault interrupted this operation. No further action was applied.' : message,
errorId
};
};