Four Js Development Tools Forum

General => Ask Reuben => Topic started by: Reuben B. on May 05, 2020, 06:54:54 am

Title: Ask Reuben 16 - When Things Go Wrong - Part 3 of 3 - Exception Handling
Post by: Reuben B. on May 05, 2020, 06:54:54 am
In this third part of a three part series dealing with how you can handle errors gracefully whilst at the same time capturing as much information as possible, this article looks at Exception Handling.

Rather than displaying a system generated dialog or stopping with no UI at all, you can configure exception handling to always call a particular function by use of the WHENEVER ANY ERROR CALL function-name directive.  When a trappable exception occurs, your function is then called, and in it you can display a nice UI to the user and perform some other background tasks before the program stops.  This can include recording the fact that the program has ended with an exception. 

if you want to ignore an exception and carry on then you can use the TRY/CATCH block.  In the event of an exception inside the TRY block, the CATCH block will be executed and the program will then continue after the CATCH block.