fix(web): preserve dropdown error messages

This commit is contained in:
yyh 2026-04-30 13:48:17 +08:00
parent 871fc0256b
commit 21d2671c34
No known key found for this signature in database

View File

@ -91,10 +91,16 @@ const DropDown = ({
}
catch (e: unknown) {
let message = 'Unknown error'
const errorWithJson = typeof e === 'object' && e !== null ? e as { json?: unknown } : null
if (e instanceof Response) {
const res = await e.json() as { message?: string }
message = res?.message || message
}
else if (typeof errorWithJson?.json === 'function') {
const parseErrorResponse = errorWithJson.json as () => Promise<{ message?: string }>
const res = await parseErrorResponse()
message = res?.message || message
}
toast(message, { type: 'error' })
}
}, [dataset.id, t])