Handling errors from convex
Hey Team, is there a better way to handle/throw convex errors to the client?
I have a particular setup for one part of my app where it would be very efficient if I could simply throw the error directly from the server. Here's the way I'm handling this now
5 Replies
Application Errors | Convex Developer Hub
If you have expected ways your functions might fail, you can either return
The prefix-stripping code will work in dev deployments, but not in prod (because of this https://docs.convex.dev/functions/error-handling/#differences-in-error-reporting-between-dev-and-prod )
Error Handling | Convex Developer Hub
There are four reasons why your Convex
Ah, I see.
below seems to work. The example in the docs however shows
error.data.message
, where for me, message is undefined.
And thank you!Yeah
data
is just the argument to ConvexError, so the doc's example uses ConvexError({message: "fancy"})
which makes error.data.message
defined.
If you're passing a string to ConvexError
, your code looks great to handle itAh interesting; and thank you again!