How to set `.error` property of JavaScript queries?

Understanding how queries work in Retool is essential. In Retool, every query has two properties: .data and .error. Typically, when executing a JavaScript query, the returned value is assigned to .data. However, you might expect that a thrown error would be captured and assigned to .error. Surprisingly, running the following JavaScript query results in query.error === undefined:

throw new Error("error message");

Even trying an alternative approach, such as the one shown below, still leaves .error undefined:

throw "error message";

This raises the question: Is there a way to explicitly set the value of .error in a JavaScript query?

I would appreciate any insights or suggestions on how to handle this scenario effectively. Thank you!

Hi @yuku,

This is a bug where error isn't getting updated properly :disappointed: I don't have a timeline for when this will be ready, but I can continue to keep you updated when it's available!

1 Like