Code QuizIntermediate Retrying on API/Parse Failures
Wrapping an LLM call and JSON parse in a retry loop that must retry on both errors.
Codejavascript
async function getJson(prompt) {
for (let i = 0; i < 3; i++) {
const res = await client.responses.create({ model: "gpt-4o-mini", input: prompt });
try {
return JSON.parse(res.output_text);
} catch (e) {
return null;
}
}
}What is the bug in this retry logic?