Previous Up Next

25.4.2  Throwing exceptions

You can produce your own string to describe an error message with the throw or error or ERROR command.

Example

With the following program:

f(x):={ if (type(x)!=DOM\_INT) throw("Not an integer"); else return x; }

input:

f(12)
     
12           

since 12 is an integer.

f(1.2)

will signal an error

     
Not an integer Error: Bad Argument Value           

since 1.2 in not an integer.


Previous Up Next