Unable to catch Zod error
Hi,
I'm creating a container builder system that intakes modal values from a user and attempts to create the selected component.
I am trying to use discordjs's builders to set the data, then run the .toJSON() function, since this will try to validate the builder's data. I wanted to catch this error and notify the user what they need to adjust, however I can receiving this and not sure how to proceed:
7 Replies
cant you just try-catch it? Also This is not Zod, builders stable release isnt on Zod yet.
I try that and it still throws that error before catching it, and the discordjs builder .toJSON() validator function returns a zod error, but the error thrown canโt be caught by my try and catch, super weird
Sorry for any formatting issues Iโm on mobile rn
The toJSON from StringSelectMenuOptionBuilder for example:
Just not sure why I can't catch that error and it's getting handled some other way through sapphire
again, it's not a zod error. Yes the master branch of discordjs builders has zod but that's not the version you're using. Look at your stack trace.
I still don't understand though why I can't catch this error within a try and catch
Ah I found my issue I'm stupid, I need to try and catch the editing of the builder, I thought I could just set it then validate with the .toJSON(), sorry for the confusion ๐
you will be able to once builders with zod releases
that's what ive been saying, that builders release isnt using zod yet
Yeah I was very confused with how their git worked ๐
Sorry for the confusion