Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Change default error formatting from pretty to colorless #579

Closed
schickling opened this issue Mar 17, 2020 · 3 comments
Closed

Change default error formatting from pretty to colorless #579

schickling opened this issue Mar 17, 2020 · 3 comments
Labels
kind/improvement An improvement to existing feature and code. topic: dx
Milestone

Comments

@schickling
Copy link
Member

schickling commented Mar 17, 2020

Problem

When an error is thrown in Prisma Client currently the error is "pretty printed" by default (see spec) which is making use of ASCII colors. While this provides a better DX in environments which support ASCII colors, in environments that don't provide support this results in unreadable error messages. See the list of issues below for reference:

When a user runs into this situation (i.e. an error is thrown in an environment that doesn't support ASCII colors) the error message is barely readable. While it's theoretically possible that in these cases a user could manually disable colored error formatting by setting errorFormat: 'colorless' it's an unrealistic assumption that a user would know (or intuitively assume) that the error formatting can be configured in order to get a more readable output. To make matters worse often it might be really hard to reproduce an error due to the non-idempotent nature of most applications so even if a user has figured out how to configure the error formatting correctly it might be a lot of work to reproduce the error.

Solution

I suggest to change the default error formatting from pretty to colorless in order to avoid the problem described above. I'm all in favor of trying to provide the best possible DX out of the box without further configuration but we need to do so in a safe way that avoids negative surprise.

Once we've changed the default error formatting, I suggest to collaborate with framework authors (e.g. Redwood, Nexus, ...) so these frameworks enable pretty error formatting out of the box as they can guarantee a safe environment.

We should also investigate whether there are better heuristics to safely determine whether an environment support ASCII colors.

@schickling schickling added the process/candidate Candidate for next Milestone. label Mar 17, 2020
@Jolg42
Copy link
Member

Jolg42 commented Mar 17, 2020

Current implemented specification is here https://github.com/prisma/specs/blob/master/prisma-client-js/README.md#error-formatting

@janpio janpio added topic: dx kind/improvement An improvement to existing feature and code. labels Mar 17, 2020
@macrozone
Copy link

@schickling agree. I just yesterday found out about the the formatting option. We mostly saw this errors in graphql requests, so there the pretty formatting is unreadable

@Jolg42
Copy link
Member

Jolg42 commented Mar 18, 2020

Done in c7e8afc
Spec up-to-date https://github.com/prisma/specs/tree/master/prisma-client-js

@Jolg42 Jolg42 closed this as completed Mar 18, 2020
@janpio janpio added this to the Preview 25 milestone Mar 18, 2020
@janpio janpio removed the process/candidate Candidate for next Milestone. label Mar 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/improvement An improvement to existing feature and code. topic: dx
Projects
None yet
Development

No branches or pull requests

4 participants