Reputation: 40092
I'm writing a custom function in Zoho Flow to perform some writes to Zoho Books from a web hook request.
I want the custom function to FAIL if something goes wrong (for example, if an item cannot be found). I cannot figure out how I can make this function fail. I've scoured the Zoho documentation. Can I not just throw an exception? How do I throw an exception in Deluge?
Side note: I'm sick and tired of Zoho's documentation. I've been using Zoho Books and Analytics for a couple of years now, and it's always SO difficult to find answers.
Upvotes: 1
Views: 812
Reputation: 11
You can throw a custom function exception using the throws
keyword. Refer to the Deluge script below:
info response;
if(response.get("code") == 0 && isEmpty(response.get("items"))) {
throws "Items Not Found";
}
Note: The exceptions need to be hardcoded, and variables cannot be used with `throws`.
Upvotes: 1
Reputation: 1
In addition to that: I would return a value like "Success" if no error is detected. Following the custom function you can implement a decision based on is not equal to success and proceed the flow as the default. If true you could send a notification with the error.
Upvotes: 0
Reputation: 443
You can do a variation on the following example. The example will return "Error at line : 6, Given index 10 is greater than the list size".
If you change the code to in the "Try" block to something that succeeds sometimes then an empty string will be returned on success and a non-empty string will be returned when an exception occurs.
string Throw_Exception()
{
try
{
// change this to the code that should be "tried".
my_list = List();
info my_list.get(10);
}
catch(err)
{
return err;
}
return "";
}
Upvotes: 0