1throw(n)                     Tcl Built-In Commands                    throw(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       throw - Generate a machine-readable error
9

SYNOPSIS

11       throw type message
12______________________________________________________________________________
13

DESCRIPTION

15       This command causes the current evaluation to be unwound with an error.
16       The error created is described by the type and message arguments:  type
17       must  contain  a  list  of words describing the error in a form that is
18       machine-readable (and which will form the error-code part of the result
19       dictionary),  and message should contain text that is intended for dis‐
20       play to a human being.
21
22       The stack will be unwound until the error  is  trapped  by  a  suitable
23       catch  or  try  command.  If  it  reaches  the event loop without being
24       trapped, it will be reported  through  the  bgerror  mechanism.  If  it
25       reaches the top level of script evaluation in tclsh, it will be printed
26       on the console before, in the non-interactive  case,  causing  an  exit
27       (the  behavior  in other programs will depend on the details of how Tcl
28       is embedded and used).
29
30       By convention, the words in the type argument should go from most  gen‐
31       eral to most specific.
32

EXAMPLES

34       The  following  produces an error that is identical to that produced by
35       expr when trying to divide a value by zero.
36
37              throw {ARITH DIVZERO {divide by zero}} {divide by zero}
38

SEE ALSO

40       catch(n), error(n), errorCode(n), errorInfo(n), return(n), try(n)
41

KEYWORDS

43       error, exception
44
45
46
47Tcl                                   8.6                             throw(n)
Impressum