#tanstack mutation onError doesnt handle convex error properly

12 messages · Page 1 of 1 (latest)

random plume
#

I expect that on the client side, i would just render the message, not the whole error stack

burnt epoch
#

@random plume try error.data.message, that should be what you pass in

random plume
#

hey @burnt epoch i just figured that it works if i do it like this

#

kinda hoping that convex would automatically handle the type of the thrown error

#

i probably expecting to high lol

burnt epoch
#

Say more, automatically handle how?

#

@random plume do you want to set a global handler and always toast or something?

random plume
#

im saying i dont want to add that ConvexErr type on the onError callback

#

or maybe im such a noob on error handling haha

burnt epoch
#

Ah got it, actually careful since there are other errors you could get here too! ConvexErrors are the only ones that will have messages attached, but other built-in errors can throw here too and they're just normal errors. In dev they'll have stack traces and messages and all but in prod they're more like Error("server error")

#

so as not to leak information from the backend