Skip to content

Hide error stacktrace #1249

Answered by nullndr
doteric asked this question in Q&A
Jul 6, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

You mean something like this?

const schema = z.number();

try {
  const data = schema.parse("foo");
} catch (e) {
  if (e instanceof ZodError) {
    console.log(e.issues);
  }
}

This will result in

[
  {
    code: 'invalid_type',
    expected: 'number',
    received: 'string',
    path: [],
    message: 'Expected number, received string'
  }
]

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@doteric
Comment options

@nullndr
Comment options

@doteric
Comment options

Answer selected by doteric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants