How to access the Convex Error Message
Hi EveryOne,
Right i am working on a problem and i need to access the the Convex Error message(User exceeded the trial limit) that i am passing from backend, so that i can do some basic operations on client side.
So, it would be great if someone can help me.
Thanks



9 Replies
Application Errors | Convex Developer Hub
If you have expected ways your functions might fail, you can either return
Thanks but,
how can read i this error on client side
Actually i want to check if i am getting this error and based on that i have to open a modal.
So if you could help me with that.
If you scroll down the doc, it explains how to read the error on the client:
https://docs.convex.dev/functions/error-handling/application-errors#handling-application-errors-on-the-client
Application Errors | Convex Developer Hub
If you have expected ways your functions might fail, you can either return
Thanks but i am reading undefined when consoling the errorMessage
Am i doing something wrong


Use
Thanks for helping me.
I was able found the problem .
So instead of using this
err.data as { message: string }).message
which is giving me undefined. I should have used err.data
since i am sending just a message not a object with message field.you can also use the .include method to see if the error you are looking for is in the error message.
It will be something like:
try{
// Your code here
} catch(error) {
if(error.message.includes("User exceeded the trial limit")) {
// Do something. Maybe open a modal.
} else {
console.log(error)
}
}
@DaReal This will not work in production, because the message will be redacted:
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
Oh! Wow...Thanks for letting me know. I will put that in mind.