hub.eb?material_id=366&track_id=361

Introduction to Errors


An error is produced when there is a problem in the running code. Common errors include:

  • Logical errors – when there is a flaw in the structure of a logical expression
  • Syntax errors – when there is a spelling or grammar mistake

On Error Events can be designed to deal with errors, otherwise a default error page is displayed that contains:

  • Error description
  • Name and line number of the script causing the error

Error messages can be displayed to the user using event.owner.addErrorMessage.

event.owner.addErrorMessage("An error has occured.");

This function accepts a message that is displayed to the user. By default adding an error message to a page halts further execution. This behaviour can be disabled by setting the stopProcessing parameter to false.

event.owner.addErrorMessage("An error has occured.", false);

JavaScript includes some useful methods to handle errors. try and catch statements are handy when writing code; any error found in the try statement can be dealt with in the catch statement.

When an uncaught error is encountered the default error page will display the script name and line number that threw the error. Navigating to the line referenced on the error page is often enough to highlight what needs correcting.

For more complicated bugs the Visual Debugger can be used to step through code line by line and identify issues.

Current Module

Related