Berian Chaiwa
06/13/2022, 10:01 AMRejectOnNotFound
is configured? I am trying to catch it like below but it is always escaping me:
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");
}
Irek Prucnal
06/13/2022, 10:51 AMError
. But you can register your own custom error like this:
rejectOnNotFound: (e) => new NotFoundError(e)
and catch NotFoundError
then.Irek Prucnal
06/13/2022, 10:52 AMBerian Chaiwa
06/13/2022, 10:53 AMIrek Prucnal
06/13/2022, 10:54 AMIrek Prucnal
06/13/2022, 10:55 AMaetheryx
06/13/2022, 1:39 PMerror instanceof
(PrismaClientUnknownRequestError || PrismaClientValidationError)
what you want is:
error instanceof PrismaClientUnknownRequestError ||
error instanceof PrismaClientValidationError
Berian Chaiwa
06/13/2022, 1:45 PM