### 25.4.2 Throwing exceptions

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

- throw takes str, a string describing an error.
- throw(str) generates an error with error string str, possibly to be caught by catch.

#### 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.