Select to view content in your preferred language

Add Error Handling Try Catch to Arcade Language

3695
13
04-14-2021 11:25 AM
Status: Open
Labels (1)
SylvainHotte2
Occasional Contributor

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

}

 

Tags (2)
13 Comments
LanceKirby2

One more vote!

PeterKnoop

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.

DavidStewart3

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;