Files
prowler/ui/components/providers/organizations/hooks/error-utils.ts
2026-02-25 13:16:34 +01:00

19 lines
424 B
TypeScript

interface ErrorResult {
error?: string;
errors?: Array<{ detail?: string }>;
}
export function extractErrorMessage(
response: unknown,
fallback: string,
): string {
if (!response || typeof response !== "object") {
return fallback;
}
const responseRecord = response as ErrorResult;
const detailedError = responseRecord.errors?.[0]?.detail;
return detailedError || responseRecord.error || fallback;
}