rembrembdocs

Setup and Configuration

This page explains how to configure the formatting of errors when using Prisma Client

By default, Prisma Client uses ANSI escape characters to pretty print the error stack and give recommendations on how to fix a problem. While this is very useful when using Prisma Client from the terminal, in contexts like a GraphQL API, you only want the minimal error without any additional formatting.

This page explains how error formatting can be configured with Prisma Client.

There are 3 error formatting levels:

  1. Pretty Error (default): Includes a full stack trace with colors, syntax highlighting of the code and extended error message with a possible solution for the problem.
  2. Colorless Error: Same as pretty errors, just without colors.
  3. Minimal Error: The raw error message.

In order to configure these different error formatting levels, there are two options:

Formatting via the PrismaClient constructor

Alternatively, use the PrismaClient errorFormat parameter to set the error format:

const prisma = new PrismaClient({
  errorFormat: "pretty",
});