IF ... THEN THROW "Error"
DEBUG err$ + "\n"
The TRY/THROW/CATCH/FINALLY commands are used to test if a section of code works, and to perform an action if it doesn't.
The CATCH command starts a code block which will CATCH any error that has been THROWn. In this block of code you would do something with the error message passed from the THROW command.
The CATCH command can catch exceptions from within nested functions too.
CATCH must be placed within the TRY/FINALLY block.
FOR i=0 TO 5
STDOUT "call "+i+"\n"
STDERR "Exception: " + err$ + "\n"
STDOUT "ok, done\n"
FUNCTION int_div_by_2: number%
IF MOD(number%, 2)<>0 THEN THROW "Odd: "+number%
STDOUT "dividing "+number%+"\n"
RETURN number / 2