Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/tcl/doc/BackgdErr.3

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


'\"
'\" Copyright (c) 1992-1994 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: BackgdErr.3,v 1.8 2007/12/13 15:22:30 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
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
.sp
\fBTcl_BackgroundError\fR(\fIinterp\fR)
.SH ARGUMENTS
.AS Tcl_Interp *interp
.AP Tcl_Interp *interp in
Interpreter in which the error occurred.
.BE

.SH DESCRIPTION
.PP
This procedure is typically invoked when a Tcl error occurs during
.QW "background processing"
such as executing an event handler.
When such an error occurs, the error 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
\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
in that interpreter to handle background errors by the
\fBinterp bgerror\fR command.
The registered handler command is meant to report the error
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
error itself by printing a message on the standard error file.
.PP
\fBTcl_BackgroundError\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
break exception, then all remaining error reports for the
interpreter are skipped.

.SH KEYWORDS
background, bgerror, error, interp

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].