|
NetRexx Overview, version 2.02
Copyright (c) IBM Corporation, 2001. All rights reserved. © | 22 May 2001 |
| [previous | contents | next] |
Exceptions are also raised when various errors occur, such as attempting to divide a number by zero. For example:
say 'Please enter a number:'
number=ask
do
say 'The reciprocal of' number 'is:' 1/number
catch Exception
say 'Sorry, could not divide "'number'" into 1'
say 'Please try again.'
end
Here, the catch instruction will catch any exception that is
raised when the division is attempted (conversion error, divide by zero,
etc.), and any instructions that follow it are then executed. If no
exception is raised, the catch instruction (and any
instructions that follow it) are ignored.
Any of the control instructions that end with end (do, loop, or select) may be modified with one or more catch instructions to handle exceptions.
From
The NetRexx Language by
Mike Cowlishaw,