Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to use generic http messages in Prisma exception filter #72

Closed
recursive-beast opened this issue Jul 17, 2023 · 1 comment · Fixed by #73
Closed

feat: add option to use generic http messages in Prisma exception filter #72

recursive-beast opened this issue Jul 17, 2023 · 1 comment · Fixed by #73

Comments

@recursive-beast
Copy link

Currently, the Prisma exception filter provided by the package maps Prisma exceptions to their corresponding HTTP exceptions, but the message of the HTTP exception is the same as the message of the underlying Prisma exception. This can result in error messages that are explicit.

I am willing to work on a pull request so that this response:

{
    "statusCode": 404,
    "message": "Not Found"
}

is sent instead of this response:

{
    "statusCode": 404,
    "message": "[P2025]: An operation failed because it depends on one or more records that were required but not found. No 'User' record(s) (needed to inline the relation on 'FriendInvitation' record(s)) was found for a nested connect on one-to-many relation 'receivedFriendInvitations'."
}

But I'm not sure how to approach this.

@recursive-beast recursive-beast changed the title feat: add feat: add option to use generic http messages in Prisma exception filter Jul 17, 2023
megane42 added a commit to megane42/nestjs-prisma that referenced this issue Aug 5, 2023
megane42 added a commit to megane42/nestjs-prisma that referenced this issue Aug 5, 2023
marcjulian added a commit that referenced this issue Nov 1, 2023
* add option to modify error messages, closes #72

* refactor

* avoid duplicate definitions for the error codes

* Update lib/prisma-client-exception.filter.ts

---------

Co-authored-by: Marc <8985933+marcjulian@users.noreply.github.com>
@marcjulian
Copy link
Member

The custom error message can be testet in the latest dev release.

npm i nestjs-prisma@0.23.0-dev.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants