const t = initTRPC.context<typeof createTRPCContext>().create({
transformer: superjson,
errorFormatter({ error, shape }) {
return {
...shape,
data: {
...shape.data,
zodError:
error.cause instanceof ZodError ? error.cause.flatten() : null,
apiError: ApiError.isApiError(error.cause) ? error.cause.errors : [],
errorStatuses: [
shape.data.httpStatus,
ApiError.isApiError(error.cause) ? error.cause.status : undefined,
],
},
};
},
});
const t = initTRPC.context<typeof createTRPCContext>().create({
transformer: superjson,
errorFormatter({ error, shape }) {
return {
...shape,
data: {
...shape.data,
zodError:
error.cause instanceof ZodError ? error.cause.flatten() : null,
apiError: ApiError.isApiError(error.cause) ? error.cause.errors : [],
errorStatuses: [
shape.data.httpStatus,
ApiError.isApiError(error.cause) ? error.cause.status : undefined,
],
},
};
},
});