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
}
One more vote!
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;
Interestingly, Esri has reserved some relevant keywords in Arcade:
Hopefully this idea gets approved!
Yes, please.
It is how I want to use it.
+1 to this thread.
Without a way to explicitly handle failures, engineers are forced to rely on defensive patterns and implicit failure behavior. This makes logic harder to test, harder to audit, and harder to build on top of, and harder to fix — especially when expressions cannot be easily executed or tested outside the platform.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.