Code Monkey home page Code Monkey logo

Comments (4)

milindgoel15 avatar milindgoel15 commented on May 23, 2024 1

https://github.com/milindgoel15/prisma-errors

Create a minimal repo with local sqlite, prisma and nextjs to show how errors could be better thrown. Wrote a basic error explanation in readme file

from prisma.

SevInf avatar SevInf commented on May 23, 2024

This is not a stacktrace, this is an extended pretty-printend message.
If you want to disable this formatting, you can supply { errorFormat: "minimal" } option to the client constructor. See our documentation here.

from prisma.

milindgoel15 avatar milindgoel15 commented on May 23, 2024

It seems setting errorformat to minimal has no effect on what I want/suggested. It still throws out the whole stack trace or extended pretty message. What I noticed is that the pretty printed message is just a stripped stack trace.

I think minimal should throw the last line of the pretty printed message like below:

'Argument `stock`: Invalid value provided. Expected Int or IntFieldUpdateOperationsInput, provided String.'

This is my prisma handler code:

import { PrismaClient } from "@prisma/client";

const prismaClientSingleton = () => {
   return new PrismaClient({
      errorFormat: "minimal",
   });
};

declare global {
   var prisma: undefined | ReturnType<typeof prismaClientSingleton>;
}

const prisma = global.prisma ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") global.prisma = prisma;

Just to note, does adding the options require any change to above code? Server restart needed? Do cache needs to be cleared?

My current workaround is to split everything in the message and return the last string.

from prisma.

janpio avatar janpio commented on May 23, 2024

Can you please provide a full example of the output or return you are getting with the error? RIght now you are just describing it, but we have not actually seen what the problem is. Optimally you also provide a minimal example for us how to reproduce it, so we can play around with it ourselves. Thank you.

from prisma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.