Improve +error.svelte handling

This commit is contained in:
2026-05-16 19:19:31 +01:00
parent b51845528f
commit 07579310b2
4 changed files with 43 additions and 27 deletions

View File

@@ -31,6 +31,7 @@ export function ThrowApiError(e: unknown): never {
// Map ApiError 'code' values
if (e instanceof ApiError) {
console.error(JSON.stringify(e), e.code, "ERRCODE")
let status = 500;
if (e.code === 'AUTH') {
status = 401;
@@ -53,6 +54,7 @@ export function ThrowApiError(e: unknown): never {
// Fallback for other error kind
const genericMessage = e instanceof Error ? e.message : 'An unexpected error occurred.';
console.log(e)
throw error(500, {
message: genericMessage,
name: 'CRITICAL_ERROR',