tanstack mutation onError doesnt handle convex error properly
I expect that on the client side, i would just render the message, not the whole error stack
6 Replies
@ibrahimyaacob try
error.data.message
, that should be what you pass in
see https://docs.convex.dev/functions/error-handling/application-errorshey @ballingt 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
Say more, automatically handle how?
@ibrahimyaacob do you want to set a global handler and always toast or something?
im saying i dont want to add that ConvexErr type on the onError callback
or maybe im such a noob on error handling haha
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
whereas a ConvexError always has the message / data attached