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
32              catch {...} errMsg
33              set savedInfo $::errorInfo
34              ...
35              error $errMsg $savedInfo
36
37       When  working  with Tcl 8.5 or later, the following code should be used
38       instead:
39
40              catch {...} errMsg options
41              ...
42              return -options $options $errMsg
43
44       If the code argument is present,  then  its  value  is  stored  in  the
45       -errorcode  return option.  The -errorcode return option is intended to
46       hold a machine-readable description of the error in  cases  where  such
47       information is available; see the return manual page for information on
48       the proper format for this option's value.
49

EXAMPLE

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

SEE ALSO

58       catch(n), return(n)
59

KEYWORDS

61       error, exception
62
63
64
65Tcl                                                                   error(n)
Impressum