Promotic
WikipediaLinkedInYoutubeTwitterFacebook

try...catch - statement of language JavaScript

Description:
Implements error handling.
Syntax:

try

{

  try-statemens

{

catch(err)

{

  catch-statements

}

 
try-statements Tracked script code
err Object containing properties that can be used to identify additional details regarding the error:
- name: Error name. This is just an error type identifier, for example "RangeError", "SyntaxError", "TypeError" ...
- message: Error description. Contains detailed description, sometimes including the nomber of row where the error occured.
catch-statements Script code executed while the error occured
Note:
If an error occurs in any command in the try-statements section (e.g. division by zero, calling undefined method, ...) then the script is not terminated (the script would be terminated if the try command is not used), but it jumps into the catch-statements section.
 
The whole command consists of try and catch sections that are compulsory. There is also the finally section that is not used by the PROMOTIC system and therefore not described in this documentation.
 
For similar purpose in the VBScript language is used the command On Error.
Example:
Processing of script error (division by zero)
try
{
  var x = 0;
  var y = 10 / x;
}
catch(err)
{
  Pm.Debug("error script: " + err.message);
}
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice