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

NotFoundError not exported #14209

Closed
PatrikValkovic opened this issue Jul 8, 2022 · 6 comments
Closed

NotFoundError not exported #14209

PatrikValkovic opened this issue Jul 8, 2022 · 6 comments
Labels
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.

Comments

@PatrikValkovic
Copy link

Bug description

When user uses rejectOnNotFound or findFirstOrThrow/findUniqueOrThrow, there is no way how to catch this exception specifically. Because Prisma doesn't export NotFoundError, user can't use instance operator and therefore can decide only based on the error message.

I believe the NotFoundError should be exported and therefore I set this up as a bug.

How to reproduce

Run prisma generate and inspect the generated file.

Expected behavior

There is NotFoundError exported, so the user can decide using check error instanceof Prisma.NotFoundError.

Prisma information

No schema or queries are neccessary.

Environment & setup

Is environment agnostic.

Prisma Version

I tried prisma clients in versions 3.13.0, 3.15.2 and 4.0.0.

@PatrikValkovic PatrikValkovic added the kind/bug A reported bug. label Jul 8, 2022
@janpio
Copy link
Member

janpio commented Jul 8, 2022

I think this was already fixed via #14076 Agree?
It should be available in the current dev version for testing, and later this month in Prisma 4.1.0.

@bbenezech

This comment was marked as outdated.

@pimeys pimeys added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. labels Jul 11, 2022
@janpio

This comment was marked as outdated.

@aqrln

This comment was marked as outdated.

@janpio
Copy link
Member

janpio commented Nov 18, 2022

@PatrikValkovic Can you confirm that the PR above solved your problem?

@miguelff
Copy link
Contributor

@PatrikValkovic NotFoundError was an implementation detail when findFirstOrThrow and findUniqueOrThrow where emulated on the client rather than implemented on the engine. Since 4.6.0, the error became deprecated and converted to a PrismaClientKnownRequestError. If you needed to perform conditional checks on this type of error, you could rely on its error code. The one for this error is "P2025".

/**
 * @deprecated please don´t rely on type checks to this error anymore.
 * This will become a PrismaClientKnownRequestError with code P2025
 * in the future major version of the client
 */
export declare class NotFoundError extends PrismaClientKnownRequestError {
    constructor(message: string);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

6 participants