fix: 题库生成功能全面修复 - create方法templateId传参、异常改为BadRequest、前端错误消息透传

This commit is contained in:
Developer
2026-05-15 09:55:03 +08:00
parent 186423d172
commit b70dc68a85
2 changed files with 21 additions and 10 deletions
+6 -1
View File
@@ -146,7 +146,12 @@ export const questionBankService = {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ count, knowledgeBaseContent }),
});
if (!response.ok) throw new Error('Failed to generate questions');
if (!response.ok) {
const errBody = await response.text().catch(() => '');
let msg = 'Failed to generate questions';
try { const parsed = JSON.parse(errBody); if (parsed.message) msg = parsed.message; } catch {}
throw new Error(msg);
}
return await response.json();
},