Skip to content

No way to catch error in findUniqueOrThrow via middleware #16354

@janpio

Description

@janpio

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)

Metadata

Metadata

Assignees

Labels

bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions