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       The  -errorinfo return option of an interpreter is used to accumulate a
21       stack trace of what was in progress when an error occurred;  as  nested
22       commands unwind, the Tcl interpreter adds information to the -errorinfo
23       return option.  If the info argument is present, it is used to initialā€
24       ize  the  -errorinfo  return  options and the first increment of unwind
25       information will not be added by the Tcl interpreter.  In other  words,
26       the  command  containing the error command will not appear in the stack
27       trace; in its place will be info.  Historically, this feature had  been
28       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       When  working  with Tcl 8.5 or later, the following code should be used
36       instead:
37              catch {...} errMsg options
38              ...
39              return -options $options $errMsg
40
41       If the code argument is present,  then  its  value  is  stored  in  the
42       -errorcode  return option.  The -errorcode return option is intended to
43       hold a machine-readable description of the error in  cases  where  such
44       information is available; see the return manual page for information on
45       the proper format for this option's value.
46

EXAMPLE

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

SEE ALSO

55       catch(n), return(n)
56
57

KEYWORDS

59       error
60
61
62
63Tcl                                                                   error(n)
Impressum