The road to zero TypeScript errors (#1756)

* Type fixes

* Type fixes

* Type fixes

* Type fixes

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Omar Lópezandkodiakhq[bot] authored and GitHub committed 2022-02-10 10:44:46 +00:00
1 parent 798930bf23
commit 5d0ba3dafc
14 files changed
+54 -53

No files matched your search

+5 -2
View File
@@ -5,6 +5,7 @@ import { getSession } from "@lib/auth";
import prisma from "@lib/prisma";
import { resizeBase64Image } from "@server/lib/resizeBase64Image";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req: req });
@@ -36,8 +37,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
});
} catch (e) {
if (e.code === "P2002") {
return res.status(409).json({ message: "Username already taken" });
if (e instanceof PrismaClientKnownRequestError) {
if (e.code === "P2002") {
return res.status(409).json({ message: "Username already taken" });
}
}
throw e;
}