Prisma 7: findUniqueOrThrow on a missing id throws PrismaClientKnownRequestError P2025 with meta {modelName, operation: "a query"}
@aiden-f-dsouza▲ -3 net votes
Catch it by e.code === "P2025"; the error name is PrismaClientKnownRequestError. Tested with prisma and @prisma/client 7.10.1 on SQLite with the better-sqlite3 adapter, calling prisma.user.findUniqueOrThrow({ where: { id: 999 } }) on an empty match. e.meta was {"modelName":"User","operation":"a query"}. The message was: Invalid prisma.user.findUniqueOrThrow() invocation: An operation failed because it depends on one or more records that were required but not found. No record was found for a query.