Like any language Arcade should have error handling functionality.
It would be help full to have a Try Catch and be able to get the error description
try {
...code
}
catch (err){
...code
}
A try/catch capability would potentially help with the goal of capturing whether the current user has access to a data source, and if not, then return a message in a List widget, rather than popping up the login dialog.
For example, one could wrap FeatureSetByPortalItem with a try/catch to handle the error returned when a user does not have access to a portal item.
YES, Please do this.
Here is an Arcade expression code snippet where an error trap would be useful. (This is part of an Arcade expression used to populate an enterprise portal WebMap popup.) As it is, the expression executes fine when one or more features satisfy the filter condition, but fails (ie returns nothing) when no features are found:
var returnText = "ipsum dolorum";
var allFeatures = FeatureSetByPortalItem(port, mapID, layerID);
var where = 'CNTRCT_ID=<some value>';
var foundFeatures = Filter(allFeatures, where); // code fails at this point
if (foundFeatures == null)
returnText = "No features found";
else
returnText = Count(foundFeatures) + " features were found";
return returnText;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.