summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/BackgdErr.351
-rw-r--r--doc/interp.n46
2 files changed, 58 insertions, 39 deletions
diff --git a/doc/BackgdErr.3 b/doc/BackgdErr.3
index 3309d25..ba53dc6 100644
--- a/doc/BackgdErr.3
+++ b/doc/BackgdErr.3
@@ -5,59 +5,76 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: BackgdErr.3,v 1.8 2007/12/13 15:22:30 dgp Exp $
+'\" RCS: @(#) $Id: BackgdErr.3,v 1.9 2008/12/09 20:16:29 dgp Exp $
'\"
.so man.macros
.TH Tcl_BackgroundError 3 7.5 Tcl "Tcl Library Procedures"
.BS
.SH NAME
-Tcl_BackgroundError \- report Tcl error that occurred in background processing
+Tcl_BackgroundException, Tcl_BackgroundError \- report Tcl exception that occurred in background processing
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
+\fBTcl_BackgroundException\fR(\fIinterp, code\fR)
+.sp
\fBTcl_BackgroundError\fR(\fIinterp\fR)
.SH ARGUMENTS
.AS Tcl_Interp *interp
.AP Tcl_Interp *interp in
-Interpreter in which the error occurred.
+Interpreter in which the exception occurred.
+.AP int code in
+The exceptional return code to be reported.
.BE
.SH DESCRIPTION
.PP
-This procedure is typically invoked when a Tcl error occurs during
+This procedure is typically invoked when a Tcl exception (any
+return code other than TCL_OK) occurs during
.QW "background processing"
such as executing an event handler.
-When such an error occurs, the error condition is reported to Tcl
+When such an exception occurs, the condition is reported to Tcl
or to a widget or some other C code, and there is not usually any
-obvious way for that code to report the error to the user.
-In these cases the code calls \fBTcl_BackgroundError\fR with an
+obvious way for that code to report the exception to the user.
+In these cases the code calls \fBTcl_BackgroundException\fR with an
\fIinterp\fR argument identifying the interpreter in which the
-error occurred. At the time \fBTcl_BackgroundError\fR is invoked,
-the interpreter's result is expected to contain an error message.
-\fBTcl_BackgroundError\fR will invoke the command registered
+exception occurred, and a \fIcode\fR argument holding the return
+code value of the exception. The state of the interpreter, including
+any error message in the interpreter result, and the values of
+any entries in the return options dictionary, is captured and
+saved. \fBTcl_BackgroundException\fR then arranges for the event
+loop to invoke at some later time the command registered
in that interpreter to handle background errors by the
-\fBinterp bgerror\fR command.
-The registered handler command is meant to report the error
+\fBinterp bgerror\fR command, passing the captured values as
+arguments.
+The registered handler command is meant to report the exception
in an application-specific fashion. The handler command
receives two arguments, the result of the interp, and the
return options of the interp at the time the error occurred.
If the application registers no handler command, the default
handler command will attempt to call \fBbgerror\fR to report
the error. If an error condition arises while invoking the
-handler command, then \fBTcl_BackgroundError\fR reports the
+handler command, then \fBTcl_BackgroundException\fR reports the
error itself by printing a message on the standard error file.
.PP
-\fBTcl_BackgroundError\fR does not invoke the handler command immediately
+\fBTcl_BackgroundException\fR does not invoke the handler command immediately
because this could potentially interfere with scripts that are in process
at the time the error occurred.
Instead, it invokes the handler command later as an idle callback.
.PP
-It is possible for many background errors to accumulate before
-the handler command is invoked. When this happens, each of the errors
-is processed in order. However, if the handle command returns a
+It is possible for many background exceptions to accumulate before
+the handler command is invoked. When this happens, each of the exceptions
+is processed in order. However, if the handler command returns a
break exception, then all remaining error reports for the
interpreter are skipped.
+.PP
+The \fBTcl_BackgroundError\fR routine is an older and simpler interface
+useful when the exception code reported is \fBTCL_ERROR\fR. It is
+equivalent to:
+.PP
+.CS
+Tcl_BackgroundException(interp, TCL_ERROR);
+.CE
.SH KEYWORDS
background, bgerror, error, interp
diff --git a/doc/interp.n b/doc/interp.n
index c986519..8e06fd3 100644
--- a/doc/interp.n
+++ b/doc/interp.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: interp.n,v 1.41 2008/10/17 10:22:25 dkf Exp $
+'\" RCS: @(#) $Id: interp.n,v 1.42 2008/12/09 20:16:29 dgp Exp $
'\"
.so man.macros
.TH interp n 8.6 Tcl "Tcl Built-In Commands"
@@ -138,12 +138,12 @@ as the current names of the commands).
.TP
\fBinterp bgerror \fIpath\fR ?\fIcmdPrefix\fR?
.
-This command either gets or sets the current background error handler
+This command either gets or sets the current background exception handler
for the interpreter identified by \fIpath\fR. If \fIcmdPrefix\fR is
-absent, the current background error handler is returned, and if it is
+absent, the current background exception handler is returned, and if it is
present, it is a list of words (of minimum length one) that describes
-what to set the interpreter's background error to. See the
-\fBBACKGROUND ERROR HANDLING\fR section for more details.
+what to set the interpreter's background exception handler to. See the
+\fBBACKGROUND EXCEPTION HANDLING\fR section for more details.
.TP
\fBinterp\fR \fBcancel \fR?\fB\-unwind\fR? ?\fB\-\|\-\fR? ?\fIpath\fR? ?\fIresult\fR?
.VS 8.6
@@ -395,12 +395,12 @@ does not have to be equal to \fIsrcCmd\fR.
.TP
\fIslave \fBbgerror\fR ?\fIcmdPrefix\fR?
.
-This command either gets or sets the current background error handler
+This command either gets or sets the current background exception handler
for the \fIslave\fR interpreter. If \fIcmdPrefix\fR is
-absent, the current background error handler is returned, and if it is
+absent, the current background exception handler is returned, and if it is
present, it is a list of words (of minimum length one) that describes
-what to set the interpreter's background error to. See the
-\fBBACKGROUND ERROR HANDLING\fR section for more details.
+what to set the interpreter's background exception handler to. See the
+\fBBACKGROUND EXCEPTION HANDLING\fR section for more details.
.TP
\fIslave \fBeval \fIarg \fR?\fIarg ..\fR?
.
@@ -748,8 +748,8 @@ This option (common for all limit types) specifies (if non-empty) a Tcl script
to be executed in the global namespace of the interpreter reading and writing
the option when the particular limit in the limited interpreter is exceeded.
The callback may modify the limit on the interpreter if it wishes the limited
-interpreter to continue executing. If the callback generates an error, it is
-reported through the background error mechanism (see \fBBACKGROUND ERROR
+interpreter to continue executing. If the callback generates an exception, it is
+reported through the background exception mechanism (see \fBBACKGROUND EXCEPTION
HANDLING\fR). Note that the callbacks defined by one interpreter are
completely isolated from the callbacks defined by another, and that the order
in which those callbacks are called is undefined.
@@ -792,21 +792,23 @@ these conditions, it should hide the \fBinterp\fR command in the child and
then use aliases and the \fBinterp invokehidden\fR subcommand to provide such
access as it chooses to the \fBinterp\fR command to the limited master as
necessary.
-.SH "BACKGROUND ERROR HANDLING"
+.SH "BACKGROUND EXCEPTION HANDLING"
.PP
-When an error happens in a situation where it cannot be reported directly up
+When an exception happens in a situation where it cannot be reported directly up
the stack (e.g. when processing events in an \fBupdate\fR or \fBvwait\fR call)
-the error is instead reported through the background error handling mechanism.
-Every interpreter has a background error handler registered; the default error
+the exception is instead reported through the background exception handling mechanism.
+Every interpreter has a background exception handler registered; the default exception
handler arranges for the \fBbgerror\fR command in the interpreter's global
-namespace to be called, but other error handlers may be installed and process
-background errors in substantially different ways.
+namespace to be called, but other exception handlers may be installed and process
+background exceptions in substantially different ways.
.PP
-A background error handler consists of a non-empty list of words to which will
+A background exception handler consists of a non-empty list of words to which will
be appended two further words at invocation time. The first word will be the
-error message string, and the second will a dictionary of return options (this
-is also the sort of information that can be obtained by trapping a normal
-error using \fBcatch\fR of course.) The resulting list will then be executed
+interpreter result at time of the exception, typically an error message,
+and the second will be the dictionary of return options at the time of
+the exception. These are the same values that \fBcatch\fR can capture
+when it controls script evaluation in a non-background situation.
+The resulting list will then be executed
in the interpreter's global namespace without further substitutions being
performed.
.SH CREDITS
@@ -849,7 +851,7 @@ set i [\fBinterp create\fR]
}
.CE
.SH "SEE ALSO"
-bgerror(n), load(n), safe(n), Tcl_CreateSlave(3), Tcl_Eval(3)
+bgerror(n), load(n), safe(n), Tcl_CreateSlave(3), Tcl_Eval(3), Tcl_BackgroundException(3)
.SH KEYWORDS
alias, master interpreter, safe interpreter, slave interpreter
'\"Local Variables: