NAME
Tcl_AddErrorInfo - record information about where an error occurred

SYNOPSIS
#include <tcl.h>

char *
Tcl_AddErrorInfo(interp, message)

ARGUMENTS
Interpreter in which to record information. Name of desired variable. Identifying string to record in errorInfo variable.

DESCRIPTION

Whenever Tcl_Eval returns a TCL_ERROR return code, it also places information in a global variable errorInfo that describes the command that was being executed when the error occurred. If multiple commands or procedures were nested when the error occurred, additional information gets added to errorInfo as the TCL_ERROR code is passed upwards. Eventually, errorInfo will give a complete trace of the activity that was in progress when the error occurred.

The procedure Tcl_AddErrorInfo may be invoked to record additional information about what was happening when an error occurred. For example, the source command uses this procedure to record the name of the file being processed and the line number on which the error occurred; for Tcl procedures, the procedure name and line number within the procedure are recorded, and so on. The extra information is contained in the message argument, and is normally enclosed in parentheses. If Tcl_AddErrorInfo is to be called, it should be called by code that invokes Tcl_Eval; Tcl_AddErrorInfo should be called just after Tcl_Eval returns TCL_ERROR. In calling Tcl_AddErrorInfo, you may find it useful to use the errorLine field of the interpreter (see the Tcl_Interp manual entry for details).

KEYWORDS
error, stack, trace, variable