Enhance upload functionality with genre selection and validation; refactor session cookie handling
CI/CD / WebPlayer (push) Successful in 39s
CI/CD / Deploy (push) Canceled after 0s
CI/CD / BackEnd (push) Canceled after 39s

This commit is contained in:
2026-09-23 18:33:21 +02:00
parent 5efd59826b
commit a7929c0ac9
11 changed files with 200 additions and 23 deletions
+20 -2
View File
@@ -52,9 +52,27 @@ export function unwrapOrError<T>(
return result.data;
}
export function apiErrorDetail(error: unknown): string | undefined {
if (typeof error !== 'object' || error === null) return undefined;
const { errors, detail, title } = error as {
errors?: Record<string, unknown>;
detail?: unknown;
title?: unknown;
};
if (errors && typeof errors === 'object') {
const messages = Object.values(errors)
.flat()
.filter((entry): entry is string => typeof entry === 'string');
if (messages.length > 0) return messages.join(' ');
}
if (typeof detail === 'string' && detail !== '') return detail;
if (typeof title === 'string' && title !== '') return title;
return undefined;
}
export function unwrapOrFail(
result: { error?: unknown },
message: string
): ActionFailure<{ message: string }> | undefined {
return result.error ? fail(502, { message }) : undefined;
): ActionFailure<{ message: string; detail?: string }> | undefined {
return result.error ? fail(502, { message, detail: apiErrorDetail(result.error) }) : undefined;
}