1 |
578 |
markom |
'\"
|
2 |
|
|
'\" Copyright (c) 1993 The Regents of the University of California.
|
3 |
|
|
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
4 |
|
|
'\"
|
5 |
|
|
'\" See the file "license.terms" for information on usage and redistribution
|
6 |
|
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
7 |
|
|
'\"
|
8 |
|
|
'\" RCS: @(#) $Id: error.n,v 1.1.1.1 2002-01-16 10:25:24 markom Exp $
|
9 |
|
|
'\"
|
10 |
|
|
.so man.macros
|
11 |
|
|
.TH error n "" Tcl "Tcl Built-In Commands"
|
12 |
|
|
.BS
|
13 |
|
|
'\" Note: do not modify the .SH NAME line immediately below!
|
14 |
|
|
.SH NAME
|
15 |
|
|
error \- Generate an error
|
16 |
|
|
.SH SYNOPSIS
|
17 |
|
|
\fBerror \fImessage\fR ?\fIinfo\fR? ?\fIcode\fR?
|
18 |
|
|
.BE
|
19 |
|
|
|
20 |
|
|
.SH DESCRIPTION
|
21 |
|
|
.PP
|
22 |
|
|
Returns a TCL_ERROR code, which causes command interpretation to be
|
23 |
|
|
unwound. \fIMessage\fR is a string that is returned to the application
|
24 |
|
|
to indicate what went wrong.
|
25 |
|
|
.PP
|
26 |
|
|
If the \fIinfo\fR argument is provided and is non-empty,
|
27 |
|
|
it is used to initialize the global variable \fBerrorInfo\fR.
|
28 |
|
|
\fBerrorInfo\fR is used to accumulate a stack trace of what
|
29 |
|
|
was in progress when an error occurred; as nested commands unwind,
|
30 |
|
|
the Tcl interpreter adds information to \fBerrorInfo\fR. If the
|
31 |
|
|
\fIinfo\fR argument is present, it is used to initialize
|
32 |
|
|
\fBerrorInfo\fR and the first increment of unwind information
|
33 |
|
|
will not be added by the Tcl interpreter. In other
|
34 |
|
|
words, the command containing the \fBerror\fR command will not appear
|
35 |
|
|
in \fBerrorInfo\fR; in its place will be \fIinfo\fR.
|
36 |
|
|
This feature is most useful in conjunction with the \fBcatch\fR command:
|
37 |
|
|
if a caught error cannot be handled successfully, \fIinfo\fR can be used
|
38 |
|
|
to return a stack trace reflecting the original point of occurrence
|
39 |
|
|
of the error:
|
40 |
|
|
.CS
|
41 |
|
|
\fBcatch {...} errMsg
|
42 |
|
|
set savedInfo $errorInfo
|
43 |
|
|
\&...
|
44 |
|
|
error $errMsg $savedInfo\fR
|
45 |
|
|
.CE
|
46 |
|
|
.PP
|
47 |
|
|
If the \fIcode\fR argument is present, then its value is stored
|
48 |
|
|
in the \fBerrorCode\fR global variable. This variable is intended
|
49 |
|
|
to hold a machine-readable description of the error in cases where
|
50 |
|
|
such information is available; see the \fBtclvars\fR manual
|
51 |
|
|
page for information on the proper format for the variable.
|
52 |
|
|
If the \fIcode\fR argument is not
|
53 |
|
|
present, then \fBerrorCode\fR is automatically reset to
|
54 |
|
|
``NONE'' by the Tcl interpreter as part of processing the
|
55 |
|
|
error generated by the command.
|
56 |
|
|
|
57 |
|
|
.SH KEYWORDS
|
58 |
|
|
error, errorCode, errorInfo
|