⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adderrinfo.3

📁 linux系统下的音频通信
💻 3
字号:
'\"'\" Copyright (c) 1989-1993 The Regents of the University of California.'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) AddErrInfo.3 1.28 97/06/12 13:39:53'\" .so man.macros.TH Tcl_AddErrorInfo 3 7.5 Tcl "Tcl Library Procedures".BS.SH NAMETcl_AddObjErrorInfo, Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_PosixError \- record information about errors.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.sp\fBTcl_AddObjErrorInfo\fR(\fIinterp, message, length\fR).sp\fBTcl_AddErrorInfo\fR(\fIinterp, message\fR).sp\fBTcl_SetObjErrorCode\fR(\fIinterp, errorObjPtr\fR).sp\fBTcl_SetErrorCode\fR(\fIinterp, element, element, ... \fB(char *) NULL\fR).spchar *\fBTcl_PosixError\fR(\fIinterp\fR).SH ARGUMENTS.AS Tcl_Interp *message.AP Tcl_Interp *interp inInterpreter in which to record information..AP char *message inFor \fBTcl_AddObjErrorInfo\fR,this points to the first byte of an array of bytescontaining a string to record in the \fBerrorInfo\fR variable.This byte array may contain embedded null bytesunless \fIlength\fR is negative.For \fBTcl_AddErrorInfo\fR,this is a conventional C string to record in the \fBerrorInfo\fR variable..AP int length inThe number of bytes to copy from \fImessage\fR whensetting the \fBerrorInfo\fR variable.If negative, all bytes up to the first null byte are used..AP Tcl_Obj *errorObjPtr inThis variable \fBerrorCode\fR will be set to this value..AP char *element inString to record as one element of \fBerrorCode\fR variable.Last \fIelement\fR argument must be NULL..BE.SH DESCRIPTION.PPThese procedures are used to manipulate two Tcl global variablesthat hold information about errors.The variable \fBerrorInfo\fR holds a stack trace of theoperations that were in progress when an error occurred,and is intended to be human-readable.The variable \fBerrorCode\fR holds a list of items thatare intended to be machine-readable.The first item in \fBerrorCode\fR identifies the class oferror that occurred(e.g. POSIX means an error occurred in a POSIX system call)and additional elements in \fBerrorCode\fR hold additional piecesof information that depend on the class.See the Tcl overview manual entry for details on the variousformats for \fBerrorCode\fR..PPThe \fBerrorInfo\fR variable is gradually built up as anerror unwinds through the nested operations.Each time an error code is returned to \fBTcl_EvalObj\fR(or \fBTcl_Eval\fR, which calls \fBTcl_EvalObj\fR)it calls the procedure \fBTcl_AddObjErrorInfo\fR to addadditional text to \fBerrorInfo\fR describing thecommand that was being executed when the error occurred.By the time the error has been passed all the way backto the application, it will contain a complete traceof the activity in progress when the error occurred..PPIt is sometimes useful to add additional information to\fBerrorInfo\fR beyond what can be supplied automaticallyby \fBTcl_EvalObj\fR.\fBTcl_AddObjErrorInfo\fR may be used for this purpose:its \fImessage\fR and \fIlength\fR arguments describe an additionalstring to be appended to \fBerrorInfo\fR.For example, the \fBsource\fR command calls \fBTcl_AddObjErrorInfo\fRto record the name of the file being processed and theline number on which the error occurred;for Tcl procedures, the procedure name and line numberwithin the procedure are recorded, and so on.The best time to call \fBTcl_AddObjErrorInfo\fR is just after\fBTcl_EvalObj\fR has returned \fBTCL_ERROR\fR.In calling \fBTcl_AddObjErrorInfo\fR, you may find it useful touse the \fBerrorLine\fR field of the interpreter (see the\fBTcl_Interp\fR manual entry for details)..PP\fBTcl_AddErrorInfo\fR resembles \fBTcl_AddObjErrorInfo\fRbut differs in initializing \fBerrorInfo\fR from the stringvalue of the interpreter's resultif the error is just starting to be logged.It does not use the result as a Tcl objectso any embedded null characters in the resultwill cause information to be lost.It also takes a conventional C string in \fImessage\fRinstead of \fBTcl_AddObjErrorInfo\fR's counted string..PPThe procedure \fBTcl_SetObjErrorCode\fR is used to set the\fBerrorCode\fR variable. \fIerrorObjPtr\fR contains a list objectbuilt up by the caller. \fBerrorCode\fR is set to thisvalue. \fBTcl_SetObjErrorCode\fR is typically invoked just before returning an error in an object command. If an error isreturned without calling \fBTcl_SetObjErrorCode\fR or\fBTcl_SetErrorCode\fR the Tcl interpreter automatically sets\fBerrorCode\fR to \fBNONE\fR..PPThe procedure \fBTcl_SetErrorCode\fR is also used to set the\fBerrorCode\fR variable. However, it takes one or more strings torecord instead of an object. Otherwise, it is similar to\fBTcl_SetObjErrorCode\fR in behavior..PP\fBTcl_PosixError\fRsets the \fBerrorCode\fR variable after an error in a POSIX kernel call.It reads the value of the \fBerrno\fR C variable and calls\fBTcl_SetErrorCode\fR to set \fBerrorCode\fR in the \fBPOSIX\fR format.The caller must previously have called \fBTcl_SetErrno\fR to set\fBerrno\fR; this is necessary on some platforms (e.g. Windows) where Tclis linked into an application as a shared library, or when the erroroccurs in a dynamically loaded extension. See the manual entry for\fBTcl_SetErrno\fR for more information..PP\fBTcl_PosixError\fR returns a human-readable diagnostic messagefor the error(this is the same value that will appear as the third elementin \fBerrorCode\fR).It may be convenient to include this string as part of theerror message returned to the application inthe interpreter's result..PPIt is important to call the procedures described here rather thansetting \fBerrorInfo\fR or \fBerrorCode\fR directly with\fBTcl_ObjSetVar2\fR.The reason for this is that the Tcl interpreter keeps informationabout whether these procedures have been called.For example, the first time \fBTcl_AddObjErrorInfo\fR is calledfor an error, it clears the existing value of \fBerrorInfo\fRand adds the error message in the interpreter's result to the variablebefore appending \fImessage\fR;in subsequent calls, it just appends the new \fImessage\fR.When \fBTcl_SetErrorCode\fR is called, it sets a flag indicatingthat \fBerrorCode\fR has been set;this allows the Tcl interpreter to set \fBerrorCode\fR to \fBNONE\fRif it receives an error returnwhen \fBTcl_SetErrorCode\fR hasn't been called..PPIf the procedure \fBTcl_ResetResult\fR is called,it clears all of the state associated with\fBerrorInfo\fR and \fBerrorCode\fR(but it doesn't actually modify the variables).If an error had occurred, this will clear the error state tomake it appear as if no error had occurred after all..SH "SEE ALSO"Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_Interp, Tcl_ResetResult, Tcl_SetErrno.SH KEYWORDSerror, object, object result, stack, trace, variable

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -