What type of error does Prisma throw when `RejectO...
# orm-help
b
What type of error does Prisma throw when
RejectOnNotFound
is configured? I am trying to catch it like below but it is always escaping me:
Copy code
catch (error) {
    if (error instanceof PrismaClientKnownRequestError) {
      throw new AuthenticationError(error.name);
    } else if (
      error instanceof
      (PrismaClientUnknownRequestError || PrismaClientValidationError)
    ) {
      throw new AuthenticationError(error.message);
    }
    // Otherwise send to Sentry so we can debug
    console.log("Authentication Error", error);
    throw new ApolloError("INTERNAL SERVER ERROR", "INTERNAL_SERVER_ERROR");
  }
i
I believe it's just a plain
Error
. But you can register your own custom error like this:
Copy code
rejectOnNotFound: (e) => new NotFoundError(e)
and catch
NotFoundError
then.
And you can register that on query level, as well as on the PrismaClient, so it's your default then.
b
How do you do that?
i
the first one is the "global" configuration for all operations
a
also, you can't write this:
Copy code
error instanceof
      (PrismaClientUnknownRequestError || PrismaClientValidationError)
what you want is:
Copy code
error instanceof PrismaClientUnknownRequestError ||
      error instanceof PrismaClientValidationError
b
It doesn't work either work. I just turned off NotFound config.