Previous Up Next

12.4.11  Dealing with errors: try catch throw error ERROR

Some commands produce errors, and if your program tries to run such a command it will halt with an error. The try and catch commands help you avoid this. They to use them, put potentially problematic statements in a block following try, and immediately after the block put catch with an argument of an unused symbol, and follow that with a block of statements that can deal with the error.

try tryblock catch symbol catchblock

If tryblock doesn’t produce an error, then

catch symbol catchblock

If tryblock does produce an error, then a string describing the error is assigned to symbol, and catchblock is evaluated.


Examples.