I have a simple JS query that executes a function and makes no external API calls or does anything else fancy.
If there's an unexpected error or bug in my code (e.g.: null pointer exception, invalid array indexing, etc.), there's no way for me to write a try/catch statement to catch every single one of these (since they are not expected to fail).
However, I want to capture the error message for such failures when they do happen in an event handler so that I can log the error.
Is there a way to propagate the error to and retrieve it in the failure event handler? self.error and self.data.error are both undefined when I try to access the error in either of those.
This is a known bug. We're having the same problem in our retool error monitoring tool as well. We reproduce the error by saving the entire query state + any other global state / vars.
We use this main JS query to prepare failures to be saved
Hi there! Thanks for flagging this. It is something that we're tracking and want to ship a fix for, but I don't have an eta for the fix yet I'll post here if I get any updates
let test;
try {
test = await query.trigger();
}
catch(error) {
return "failed";
}
return test;
The catch block does not seem to be picking up on the error from the query. The catch block is never executed I'm not sure if this issue(which I thought this original post was about) is being resolved somehow by the information in your last post @Tess
The bug fix specifically addresses the issue where the error property wasn't getting updated and therefore couldn't be referenced in failure event handlers
Prior to the bug fix, the error property remained undefined, so you couldn't reference it in the failure handler:
Check out this post by @TobiasOhlsson. This should be an answer to what you're looking for. The way he went about it has totally changed how handle all my promises and possible failures.
Big Kudos to him!