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.
This commit is contained in:
@@ -1,22 +1,15 @@
|
||||
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 {
|
||||
let msg = fallback
|
||||
if (e instanceof ApiError) {
|
||||
const d = (e as ApiError & { detail?: unknown }).detail ?? e.message
|
||||
if (typeof d === 'string') msg = d
|
||||
else if (Array.isArray(d)) {
|
||||
msg = d.map((x: { msg?: string; loc?: unknown[] }) => {
|
||||
const part = x?.msg || JSON.stringify(x)
|
||||
const loc = Array.isArray(x.loc) ? x.loc.filter((p) => p !== 'body').join('.') : ''
|
||||
return loc ? `${loc}: ${part}` : part
|
||||
}).join('; ')
|
||||
} else if (d && typeof d === 'object') msg = JSON.stringify(d)
|
||||
else msg = e.message || fallback
|
||||
} else if (e instanceof Error) {
|
||||
msg = e.message || fallback
|
||||
return formatValidationDetail(d, e.message || fallback)
|
||||
}
|
||||
msg = msg.trim()
|
||||
return msg || fallback
|
||||
if (e instanceof Error) {
|
||||
const msg = e.message.trim()
|
||||
return msg || fallback
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user