Find mutation error message
Ill like to know how to get the error message from my mutations functions . I'm getting [CONVEX M(pos:addSale)] Uncaught Error: ${message} in stock\n at <anonymous> (../convex/pos.ts:14:15)\n at async Promise.all (index 0)all [as all] (<anonymous>)\n at async invokeMutation (../../node_modules/convex/src/server/impl/registration_impl.ts:24:14)\n
3 Replies
@edmarfo are you looking in the developer console in your app or the logs in the dashboard?
If you wouldn't mind sending a screenshot (feel free to dm) of what you see and what the code that threw the error is that'd be helpful
Im looking to get the error message and display in a toast. Ive used try catch and when i console.log the message in the catch block i get that but i just need to extract the message from it
Ah got it, yeah I think that's hard to get for now; the error message you get on the client has a different message.
A suggestion would be to catch the error in the backend and then return it as a string, so the return type of your function is either an error message or nothing if success
we might be able to make this error message match in the future, maybe in a custom property like
error.serverMessage
we want to put all that information in the message so we can show a server stack trace for development, but there might be ways around this