refactor(frontend): replace all as-unknown-as error casts with extractErrorCode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-20 20:54:32 +02:00
committed by marcel
parent 1a7e4ce536
commit 2914010b68
24 changed files with 116 additions and 112 deletions

View File

@@ -1,5 +1,5 @@
import { error, redirect } from '@sveltejs/kit';
import { createApiClient } from '$lib/shared/api.server';
import { createApiClient, extractErrorCode } from '$lib/shared/api.server';
import { getErrorMessage } from '$lib/shared/errors';
import { inferredRelationshipLabel } from '$lib/person/relationshipLabels';
@@ -17,8 +17,7 @@ export async function load({ params, fetch }) {
if (docResult.response.status === 401) throw redirect(302, '/login');
if (!docResult.response.ok) {
const code = (docResult.error as unknown as { code?: string })?.code;
throw error(docResult.response.status, getErrorMessage(code));
throw error(docResult.response.status, getErrorMessage(extractErrorCode(docResult.error)));
}
const document = docResult.data!;