MugetsuM
tRPC4y ago
5 replies
Mugetsu

Handling error globally

According to the docs on errors https://trpc.io/docs/v10/error-handling I should get such error object on client side when its thrown from procedure If I understand correctly. But Im having a problem with it as it doesnt seem to be typed as TRPCError on the client and dont contain few props from described in docs.

        queryCache: new QueryCache({
          onError: async (error: any) => {
            console.log(error.id);
            console.log(error.message);
            console.log(error.code);
            console.log(error.data);
            console.log(error?.data?.httpStatus === 401);
            if (
              error?.data?.httpStatus === 401 ||
              error.message === "UNAUTHORIZED"
            ) {
              await signOut({ redirect: false });
            }
          },
        }),
Screenshot_2022-11-08_at_13.33.47.png
Was this page helpful?