Files
Nexus/frontend/src/utils/apiError.ts
T
Nexus Agent 091fb97291
Nexus CI/CD / test (push) Waiting to run
Nexus CI/CD / deploy (push) Blocked by required conditions
Nexus Pre-commit Checks / quick-check (push) Waiting to run
Push async submit, Chinese 422 field labels, hide server CSV export.
Return sync/files immediately with background runner; show loc_zh in validation errors; remove servers toolbar CSV export button.
2026-06-08 23:28:26 +08:00

16 lines
519 B
TypeScript

import { ApiError } from '@/api'
import { formatValidationDetail } from '@/utils/validationErrorFormat'
/** Turn FastAPI error bodies into a human-readable string. */
export function formatApiError(e: unknown, fallback: string): string {
if (e instanceof ApiError) {
const d = (e as ApiError & { detail?: unknown }).detail ?? e.message
return formatValidationDetail(d, e.message || fallback)
}
if (e instanceof Error) {
const msg = e.message.trim()
return msg || fallback
}
return fallback
}