Runtime Error Handling

When developing a Digitise app, you should allow within your Scripts for potential errors which could occur when the app is run.

By default Script errors, such as syntax errors, which arise at runtime will display an error message box which provides information about the type of error, the Script which was running when the error occurred and the line number within the Script at which the error occurred. When the user clicks the OK button to dismiss the message box, the Script is terminated and control returns to the app.

Other errors, such as data and communications errors, errors inserting or updating records in a remote data source or errors pertaining to the operation of controls, do not display in error message boxes and have to be handled within a Script.

The error message box varies slightly from Platform to Platform but contains similar information. For example, in the Windows Desktop Client the dialog box looks like this:

Picture showing the Runtime error dialog box on a Windows device.

and on an Android device it looks like this:

Runtime error dialog box on an Android device.

The title describes the category of error, e.g. Script Error in the examples above. Below this is a user-orientated description of the problem followed by the details section at the bottom, giving more information. When the user clicks on the OK button to close the message box, the current Script will be terminated at the line specified in the details and control returns to the app.

 

The Scripting language includes a number of Statements and Methods which relate to handling potential errors at runtime. These cover turning on and off the use of popup error messages and checking for and obtaining details of any errors, allowing you to include error handling within your Scripts.

If you turn off the display of the popup error messages described above, no message will be displayed to the user in the event that an error occurs whilst the app is being run. You can, however, use the error handling Scripting Methods and Statements to check for data, comms and some other errors within your Scripts and obtain information about any errors. These Methods return the same information as would be displayed in the details section of the error message box and allow you to handle any errors within your Scripts. If you are not displaying the popup error messages for your users, you should incorporate error checking within your apps' Scripts at appropriate points to enable any errors which might occur to be caught and handled gracefully within your Scripts.

  • Syntax errors are not handled by the error handling Scripting Methods and Statements when the display of popup error message boxes is switched off and will cause your Script to terminate without displaying any message.

 

The following error handling Methods and Statements are available:

  • When running Scripts on Android devices, to improve performance, Scripts generally don't update the screen until the Script finishes, unless a call to a Method, such as MsgBox or GetControlValue, necessitates a screen update. This means you won't see some screen changes until the Script exits.

    However, if you call On Error GoTo <label> or On Error Resume Next, this deferred screen updating is turned off because if a problem were to arise during the deferred operation the Script would have already finished and the On Error Statement could no longer be executed. Calling On Error GoTo 0 will resume deferred screen updating.

    When deferred screen updating is off, if you notice reduced performance in your app, you can call On Error GoTo 0 before affected sections of your Script. However, generally, we recommend calling On Error Statements at the top or bottom of Functions and avoiding turning error handling on and off throughout a Function.

  • Errors relating to problems inserting and updating records in a remote Target database are not available via the GetLastError or GetLastDataError Methods. These errors are accessed using GetNumSyncErrors, GetSyncErrorDataSource, GetSyncErrorDescription and GetSyncErrorRecordIndex instead. These errors are not, therefore, affected by calls to the error handling Statements and Methods and must be checked independently.

 

 

More details about using any of the Methods mentioned in this topic can be found in the descriptions for the individual Methods, which can be accessed from one of the Method lists: Alphabetical List of Methods or List of Methods by Category.