# try -- catch an error

## Synopsis

• Usage:
try x then y else z
• Inputs:
• x, code
• y, code
• z, code
• Consequences:
• the code x is run; if no error or alarm occurs, then the code y is run; otherwise, the code z is run

## Description

The return value is the value returned by y or z, as the case may be.

The clause 'then y' may be omitted, in which case the return value is the value returned by x, if there is no error or alarm.

The clauses 'then y else z' may both be omitted, in which case the return value is the value returned by x, unless an error or alarm occurs, in which case null is returned.

The behavior of interrupts (other than alarms) is unaffected.

 i1 : apply(-3..3,i->try 1/i else infinity) 1 1 1 1 o1 = (- -, - -, -1, infinity, 1, -, -) 3 2 2 3 o1 : Sequence

## Caveat

We will change the behavior of this function soon so that it will be possible to catch errors of a particular type. Meanwhile, users are recommended to use this function sparingly, if at all.

## For the programmer

The object try is .