hey guys help me handle this prisma error in typescript

hey guys help me handle this prisma error in typescript
if (error instanceof Prisma.PrismaClientUnknownRequestError) {
if (error.code === 'P2002') { // 'error' is of type 'unknown'
res.status(400).json({ message: 'Username already exists' });
}
} else {
res.status(500).json({ message: 'Internal server error' });
}
if (error instanceof Prisma.PrismaClientUnknownRequestError) {
if (error.code === 'P2002') { // 'error' is of type 'unknown'
res.status(400).json({ message: 'Username already exists' });
}
} else {
res.status(500).json({ message: 'Internal server error' });
}
3 Replies
Lopen
Lopen10mo ago
That should work in typescript
ForcedToCode
ForcedToCode10mo ago
yeah i was using PrismaClientUnknownRequestError instead of PrismaClientKnownRequestError solved it
Want results from more Discord servers?
Add your server