fix: correcte error handling in question controller backend
This commit is contained in:
parent
4f0c4241b6
commit
fe51c2d1ec
1 changed files with 2 additions and 1 deletions
|
@ -106,13 +106,14 @@ export async function deleteQuestionHandler(req: Request, res: Response): Promis
|
||||||
const questionId = getQuestionId(req, res);
|
const questionId = getQuestionId(req, res);
|
||||||
|
|
||||||
if (!questionId) {
|
if (!questionId) {
|
||||||
|
res.json(404).json({ error: 'Question not found' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const question = await deleteQuestion(questionId);
|
const question = await deleteQuestion(questionId);
|
||||||
|
|
||||||
if (!question) {
|
if (!question) {
|
||||||
res.status(400).json({ error: 'Could not find nor delete question' });
|
res.status(404).json({ error: 'Could not find nor delete question' });
|
||||||
} else {
|
} else {
|
||||||
res.json(question);
|
res.json(question);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue