diff --git a/apps/backend/src/routes/questions/route.ts b/apps/backend/src/routes/questions/route.ts index ed556cf..d605c58 100644 --- a/apps/backend/src/routes/questions/route.ts +++ b/apps/backend/src/routes/questions/route.ts @@ -147,10 +147,7 @@ const questionsRoute = new Hono() ) ); - if (!queryResult.length) - throw new HTTPException(404, { - message: "The question does not exists", - }); + if (!queryResult[0]) throw notFound(); const questionData = { ...queryResult[0], @@ -256,10 +253,7 @@ const questionsRoute = new Hono() ) ); - if (!question[0]) - throw new HTTPException(404, { - message: "The question is not found", - }); + if (!question[0]) throw notFound(); if (skipTrash) { await db.delete(questions).where(eq(questions.id, questionId)); @@ -291,7 +285,7 @@ const questionsRoute = new Hono() await db.select().from(questions).where(eq(questions.id, questionId)) )[0]; - if (!question) return c.notFound(); + if (!question) throw notFound(); if (!question.deletedAt) { throw new HTTPException(400, {