From 1ef0caa18e5c3d57f4edb761db9f43f89c53729a Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Thu, 19 May 2022 00:47:15 -0700 Subject: [PATCH] add error formatting recipe --- recipes/error-formatting.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/recipes/error-formatting.md b/recipes/error-formatting.md index 176dea7..b60290c 100644 --- a/recipes/error-formatting.md +++ b/recipes/error-formatting.md @@ -15,7 +15,7 @@ export const router = trpc.router() data: { ...shape.data, zodError: - error.code === 'BAD_USER_INPUT' + error.code === 'BAD_REQUEST' && error.cause instanceof ZodError ? error.cause.flatten() : null, @@ -27,5 +27,15 @@ export const router = trpc.router() ### Usage in Vue ```html + + ``` + +Learn more about error formatting [here](https://trpc.io/docs/error-formatting).