throw(n) Tcl Built-In Commands throw(n)

```

```

# [NAME](#NAME)

throw - Generate a machine-readable error

# [SYNOPSIS](#SYNOPSIS)

**throw type message**

```

```

# [DESCRIPTION](#DESCRIPTION)

This command causes the current evaluation to be unwound with an error. The error created is described by the *type* and *message* arguments: *type* must contain a list of words describing the error in a form that is machine-readable (and which will form the error-code part of the result dictionary), and *message* should contain text that is intended for display to a human being.

The stack will be unwound until the error is trapped by a suitable **catch** or **try** command. If it reaches the event loop without being trapped, it will be reported through the **bgerror** mechanism. If it reaches the top level of script evaluation in **tclsh**, it will be printed on the console before, in the non-interactive case, causing an exit (the behavior in other programs will depend on the details of how Tcl is embedded and used).

By convention, the words in the *type* argument should go from most general to most specific.

# [EXAMPLES](#EXAMPLES)

The following produces an error that is identical to that produced by **expr** when trying to divide a value by zero.

```
throw {ARITH DIVZERO {divide by zero}} {divide by zero}
```

# [SEE ALSO](#SEE_ALSO)

[catch(n)](/man/os/tcl/catch.n), [error(n)](/man/os/tcl/error.n), [errorCode(n)](/man/os/tcl/errorCode.n), [errorInfo(n)](/man/os/tcl/errorInfo.n), [return(n)](/man/os/tcl/return.n), [try(n)](/man/os/tcl/try.n)

# [KEYWORDS](#KEYWORDS)

error, exception

8.6 Tcl

---

Document: throw(n) from tcl 9.1.0-r1 (Chainguard OS)
Source: https://downloads.sourceforge.net/project/tcl/Tcl/9.1.0/tcl9.1.0-src.tar.gz
