Nishil FalduN
Convex Community2y ago
9 replies
Nishil Faldu

Propagating errors in mutations in server actions

Helloooo. Recently, I have been thoroughly enjoying using convex mutations in server-actions but I did run into something for which I would like some help. So lets say, my mutations throw a ConvexError , I have an async function in my use server file (where all my actions are) where I call the convex mutation using fetchMutation call - which is wrapped in a try-catch - if there's an error I will try to re-throw the error. I call this async function in another file (a react component, lets say) where I catch the re-thrown error in a toast but it doesn't give the same error message I threw from backend using ConvexError and it gives me this instead: An error occurred in the Server Components render which I think is because the re-thrown error cannot be serialized. Does anyone know a way around this or have a better solution?
Was this page helpful?