error.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:2k
- '"
- '" Copyright (c) 1993 The Regents of the University of California.
- '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: error.n,v 1.3.18.1 2004/10/27 09:35:38 dkf Exp $
- '"
- .so man.macros
- .TH error n "" Tcl "Tcl Built-In Commands"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- error - Generate an error
- .SH SYNOPSIS
- fBerror fImessagefR ?fIinfofR? ?fIcodefR?
- .BE
- .SH DESCRIPTION
- .PP
- Returns a fBTCL_ERRORfR code, which causes command interpretation to be
- unwound. fIMessagefR is a string that is returned to the application
- to indicate what went wrong.
- .PP
- If the fIinfofR argument is provided and is non-empty,
- it is used to initialize the global variable fBerrorInfofR.
- fBerrorInfofR is used to accumulate a stack trace of what
- was in progress when an error occurred; as nested commands unwind,
- the Tcl interpreter adds information to fBerrorInfofR. If the
- fIinfofR argument is present, it is used to initialize
- fBerrorInfofR and the first increment of unwind information
- will not be added by the Tcl interpreter. In other
- words, the command containing the fBerrorfR command will not appear
- in fBerrorInfofR; in its place will be fIinfofR.
- This feature is most useful in conjunction with the fBcatchfR command:
- if a caught error cannot be handled successfully, fIinfofR can be used
- to return a stack trace reflecting the original point of occurrence
- of the error:
- .CS
- fBcatch {...} errMsg
- set savedInfo $errorInfo
- &...
- error $errMsg $savedInfofR
- .CE
- .PP
- If the fIcodefR argument is present, then its value is stored
- in the fBerrorCodefR global variable. This variable is intended
- to hold a machine-readable description of the error in cases where
- such information is available; see the fBtclvarsfR manual
- page for information on the proper format for the variable.
- If the fIcodefR argument is not
- present, then fBerrorCodefR is automatically reset to
- ``NONE'' by the Tcl interpreter as part of processing the
- error generated by the command.
- .SH EXAMPLE
- Generate an error if a basic mathematical operation fails:
- .CS
- if {1+2 != 3} {
- fBerrorfR "something is very wrong with addition"
- }
- .CE
- .SH "SEE ALSO"
- catch(n), return(n), tclvars(n)
- .SH KEYWORDS
- error, errorCode, errorInfo