forked from hangshuo652/aurak
fix: 题库生成功能全面修复 - create方法templateId传参、异常改为BadRequest、前端错误消息透传
This commit is contained in:
@@ -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();
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user