Logging client errors
Why the following code does not work? The create statement throws a Prisma.PrismaClientKnownRequestError with code P2002 (unique constraint violation).
I don't need specific error handling (https://www.prisma.io/docs/orm/prisma-client/debugging-and-troubleshooting/handling-exceptions-and-errors), just a raw console.log of the error.
Handling exceptions and errors (Reference) | Prisma Documentation
This page covers how to handle exceptions and errors
6 Replies
Hey @t4ut4ut4u 👋
In this case it looks like
console
is null?
Where are you deploying your app? Are you running this locally?Hi, yes i am running locally.
Here my deps:
I am wondering if this has something to do with
console
object.
Can you do a console.log("Something");
in your try block and see if that works? If it works, then we can rule out something being wrong with console
yes, console.log with random string works. Don't know if it can help but I am inside a server action (using https://next-safe-action.dev/).
@Nurul Hi, I noticed that wrapping the error with
JSON.stringify
works.Ah, that's great! Thanks for letting me know 👍