How can we check if the error is an ZodError? #2415
-
I try to write a function that transforms errors from Zod or from my backend into a readable format. But to do this i need to know if the error thrown is from Zod or my api. Is there any reliable way to check this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
My temp fix for this right now it this:
But i feel like this is really error prone. |
Beta Was this translation helpful? Give feedback.
-
created a pr for this problem: #3819 |
Beta Was this translation helpful? Give feedback.
import {ZodError} from 'zod'
error instanceof ZodError