091fb97291
Return sync/files immediately with background runner; show loc_zh in validation errors; remove servers toolbar CSV export button.
16 lines
519 B
TypeScript
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
|
|
}
|