Exceptions can be thrown in TrackVia app scripts when something unexpected happens, such as an invalid input or an error with your app script logic. These exceptions can be handled by wrapping the code inside of a try/catch block. This will allow you to catch any exceptions that are thrown and deal with them appropriately.
When handling errors, it is important to make sure that the code is as robust as possible. This means that all potential errors should be handled and any data that is received from users should be validated. Additionally, you should always log any errors that occur in order to help with debugging, and any exceptions that are thrown should be handled gracefully in order to provide the best user experience.
When an exception is thrown, the user will see an error window in the lower corner of their screen. This popup will contain the exception message and other debugging information.
//String value that a form populates
String salesPerson = currentValues["Sales Person"]
//Field doesn't have a value and that's a problem
if(salesPerson == ""){
// Exception will display as a toaster when form is submitted
throw new RuntimeException("Sales Person must have a value.")
}
In this example, the user will be presented with an error window if they attempt to submit the form without entering a value in the Sales Person field. This will inform the user that they must enter a value in order to continue and prevent the form from being submitted with an invalid value.
Comments
0 comments
Please sign in to leave a comment.