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); | ||||
| 
 | ||||
|     if (!questionId) { | ||||
|         res.json(404).json({ error: 'Question not found' }); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     const question = await deleteQuestion(questionId); | ||||
| 
 | ||||
|     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 { | ||||
|         res.json(question); | ||||
|     } | ||||
|  |  | |||
		Reference in a new issue
	
	 Adriaan Jacquet
						Adriaan Jacquet