userRouter.patch("/self", async (c) => { const reqUserId = c.get("authUser").user?.id; if (reqUserId == null) { throw new HTTPException(401); } const { name } = await c.req.json(); if (!name) { throw new HTTPException(400, { message: "Please include a new name in body." }); } return c.json({});});
userRouter.patch("/self", async (c) => { const reqUserId = c.get("authUser").user?.id; if (reqUserId == null) { throw new HTTPException(401); } const { name } = await c.req.json(); if (!name) { throw new HTTPException(400, { message: "Please include a new name in body." }); } return c.json({});});
If no json is passed in the body i get this error:
[ERROR] SyntaxError: Unexpected end of JSON input
[ERROR] SyntaxError: Unexpected end of JSON input
Is there anyway to replace this with my own error message? Like the one in my code ^ ?