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

No way to catch error in findUniqueOrThrow via middleware #16354

Closed
janpio opened this issue Nov 18, 2022 · 2 comments · Fixed by #16433
Closed

No way to catch error in findUniqueOrThrow via middleware #16354

janpio opened this issue Nov 18, 2022 · 2 comments · Fixed by #16433
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client.
Milestone

Comments

@janpio
Copy link
Member

janpio commented Nov 18, 2022

Also their is no way to catch and massage the error (to change its message for example).

With findUniqueOrThrow, in a middleware result is null and params.action is findUnique:

prismaClient.$use(async (params, next) => {
  try {
    const result = await next(params);
    return result;
  } catch (error) {
    // nothing to see here
    throw error;
  }
});

With rejectOnNotFound, the un-exported error (treatable with error.constructor.name === 'NotFoundError' btw) was thrown inside.

Originally posted by @bbenezech in #14209 (comment)

@janpio
Copy link
Member Author

janpio commented Nov 18, 2022

@bbenezech this sounds like a separate issue for me, is that right? If that's the case, could you please open a separate GitHub issue for this to avoid any confusion, and, most importantly, avoid your report being lost, since the issue @PatrikValkovic refers to has already been fixed, and someone might close it without looking at your comment.

Originally posted by @aqrln in #14209 (comment)

@miguelff
Copy link
Contributor

Tracked in #16226

@miguelff miguelff added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Nov 21, 2022
@miguelff miguelff added this to the 4.7.0 milestone Nov 24, 2022
@miguelff miguelff self-assigned this Nov 24, 2022
miguelff added a commit that referenced this issue Nov 24, 2022
miguelff added a commit that referenced this issue Nov 25, 2022
miguelff added a commit that referenced this issue Nov 28, 2022
miguelff added a commit that referenced this issue Nov 28, 2022
jkomyno pushed a commit that referenced this issue Dec 21, 2022
jkomyno pushed a commit that referenced this issue Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants