staging-org / ocean-landing-serve / src/ hooks.server.ts

import type { HandleServerError } from '@sveltejs/kit/hooks';

// Only unexpected errors get a short id, shown on the error page so a report can be matched to this log line.
export const handleError: HandleServerError = (caught) => {
	if (caught.kind !== 'unknown') return;
	const id = crypto.randomUUID().slice(0, 8);
	console.error(`[${id}] ${caught.event.url.pathname}`, caught.error);
	return { id };
};