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

NAME

8       error - Generate an error
9

SYNOPSIS

11       error message ?info? ?code?
12_________________________________________________________________
13
14

DESCRIPTION

16       Returns  a  TCL_ERROR  code,  which causes command interpretation to be
17       unwound.  Message is a string that is returned to  the  application  to
18       indicate what went wrong.
19
20       If  the  info argument is provided and is non-empty, it is used to ini‐
21       tialize the global variable errorInfo.  errorInfo is used to accumulate
22       a stack trace of what was in progress when an error occurred; as nested
23       commands unwind, the Tcl interpreter adds information to errorInfo.  If
24       the  info  argument  is present, it is used to initialize errorInfo and
25       the first increment of unwind information will not be added by the  Tcl
26       interpreter.   In other words, the command containing the error command
27       will not appear in errorInfo; in its place will be info.  This  feature
28       is most useful in conjunction with the catch command: if a caught error
29       cannot be handled successfully, info can be  used  to  return  a  stack
30       trace reflecting the original point of occurrence of the error:
31              catch {...} errMsg
32              set savedInfo $errorInfo
33              ...
34              error $errMsg $savedInfo
35
36       If the code argument is present, then its value is stored in the error‐
37       Code global variable.  This variable is intended  to  hold  a  machine-
38       readable  description  of  the error in cases where such information is
39       available; see the tclvars manual page for information  on  the  proper
40       format  for  the  variable.   If the code argument is not present, then
41       errorCode is automatically reset to ``NONE'' by the Tcl interpreter  as
42       part of processing the error generated by the command.
43

EXAMPLE

45       Generate an error if a basic mathematical operation fails:
46              if {1+2 != 3} {
47                  error "something is very wrong with addition"
48              }
49
50

SEE ALSO

52       catch(n), return(n), tclvars(n)
53
54

KEYWORDS

56       error, errorCode, errorInfo
57
58
59
60Tcl                                                                   error(n)
Impressum