Add Error Handling Try Catch to Arcade Language

04-14-2021 11:25 AM
Status: Open
Labels (1)
New Contributor II

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 {



catch (err){




Tags (2)

This is a great idea, I would use this all the time.


Thanks for raising the idea, @SylvainHotte2 @jcarlson . We've discussed various plans for adding more error management within Arcade.

We'd be interested in what scenarios you have in mind? For instance:

- catching when something has gone wrong within a library function?

- your own script logic throwing exceptions to be caught in an outer scope of the script?

- being able send your own error/exception information out of the script for the application to receive/log/act on?



Currently I use Arcade in attribute rules. I use the a lot the {"errorMessage":"a message to the user"} to send back error to the user telling them what is the cause of the error.

However, a try catch would be helpful to capture runtime error and send a more descriptive message. Here an Example. In that code sample we validate (Constraint Rule) the the new value the user entered really exist in an other table (we validate the relationship). I edit the code to simplify the example.


In this example, If the Filter returns nothing then First return Null. To prevent a runtime error I need to check for null before getting the .STATUS_CODE attribute. Depending on code there could be many of those kind of check. Also, it might be something wrong with a library, or something we did not think of. I would rewrite like this


In other scenario I written function in my arcade script (ex: recursive, reuse code, etc) I might also be interesting to be able to throw Exception instead of outputting and array like having the first element a Boolean for success or Fail, and the second for the data. 

As for sending My own Exception outside I recently see that now the full attribute rule error message we see in pro is not sent to the .Net SDK. That is good. If you could go a step further and being able to the the detail in an object (Rule Name, Error Code, Error Description, etc ) but I guess I can deserialize the Json my self. I also notice the tools like FME does not report error correctly when the is an attribute rule constraint. The is just an generic error message the the message part is just {}. 

While I have your attention, I know we are not Christmas yet, but I will be fun to be able to build our own Arcade Function Library  and Import them in the Arcade Script. Let say I create a advance TitleCase function, or other generic function that I use in many other script, Instead of copy paste the function, I could just create a library and import it. I could event share those libraries to others.

Hope it give a more detail idea of what I had in mind




Absolutely agree that having error trapping (e.g. try/catch) is an essential requirement. This is both for capturing unexpected errors from library functions and for capturing errors within our own code. Without this capability, if we use arcade to do anything slightly more complex, end users can end up with a poor user experience when things go wrong.


This gets my vote too! Real nightmare handling errors in arcade...


@RichardJShepherd  Would be great in SmartForms.  If a field calculation in Arcade errors out it locks up the SmartForm and refuses to allow the user to submit the feature because having a calculation on a field there makes that field a required field.  Unlike in Survey123, there is no "Save Draft" option.