Throwing validation error only with stack trace #963
-
|
Hi all! I'm trying to implement a try {
const response = await storeAndValidate(data)
} catch (error) {
console.error(error instanceof ZodError ? error.stack : error)
}I want to avoid having to check if So basically the code from above would become this and the resulting error logs would look the same: try {
const response = await storeAndValidate(data)
} catch (error) {
console.error(error)
}Is this possible to implement? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Try this. const logErrorStack = err => {
console.error('stack' in err ? err.stack : err)
}try {
const response = await storeAndValidate(data)
} catch (error) {
logErrorStack(error)
} |
Beta Was this translation helpful? Give feedback.
Try this.