fix: change to DashboardError

This commit is contained in:
abiyasa05 2024-08-18 19:06:22 +07:00
parent fdeca88270
commit 7daee35fee

View File

@ -11,6 +11,7 @@ import authInfo from "../../middlewares/authInfo";
import { or, eq } from "drizzle-orm"; import { or, eq } from "drizzle-orm";
import { z } from "zod"; import { z } from "zod";
import HonoEnv from "../../types/HonoEnv"; import HonoEnv from "../../types/HonoEnv";
import { notFound } from "../../errors/DashboardError";
const registerFormSchema = z.object({ const registerFormSchema = z.object({
name: z.string().min(1).max(255), name: z.string().min(1).max(255),
@ -109,9 +110,7 @@ const respondentsRoute = new Hono<HonoEnv>()
.where(eq(rolesSchema.code, "user")) .where(eq(rolesSchema.code, "user"))
.limit(1); .limit(1);
if (!role) { if (!role) throw notFound();
throw new HTTPException(500, { message: "Role 'user' not found" });
}
await trx.insert(rolesToUsers).values({ await trx.insert(rolesToUsers).values({
userId: newUser.id, userId: newUser.id,