Add SHD themed error handling
This commit is contained in:
+11
-1
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user