Debian Codegraph @

doc/BackgdErr.3

raw
1 '\"
2 '\" Copyright (c) 1992-1994 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH Tcl_BackgroundError 3 7.5 Tcl "Tcl Library Procedures"
9 .so man.macros
10 .BS
11 .SH NAME
12 Tcl_BackgroundException, Tcl_BackgroundError \- report Tcl exception that occurred in background processing
13 .SH SYNOPSIS
14 .nf
15 \fB#include <tcl.h>\fR
16 .sp
17 \fBTcl_BackgroundException\fR(\fIinterp, code\fR)
18 .sp
19 \fBTcl_BackgroundError\fR(\fIinterp\fR)
20 .SH ARGUMENTS
21 .AS Tcl_Interp *interp
22 .AP Tcl_Interp *interp in
23 Interpreter in which the exception occurred.
24 .AP int code in
25 The exceptional return code to be reported.
26 .BE
27
28 .SH DESCRIPTION
29 .PP
30 This procedure is typically invoked when a Tcl exception (any
31 return code other than TCL_OK) occurs during
32 .QW "background processing"
33 such as executing an event handler.
34 When such an exception occurs, the condition is reported to Tcl
35 or to a widget or some other C code, and there is not usually any
36 obvious way for that code to report the exception to the user.
37 In these cases the code calls \fBTcl_BackgroundException\fR with an
38 \fIinterp\fR argument identifying the interpreter in which the
39 exception occurred, and a \fIcode\fR argument holding the return
40 code value of the exception. The state of the interpreter, including
41 any error message in the interpreter result, and the values of
42 any entries in the return options dictionary, is captured and
43 saved. \fBTcl_BackgroundException\fR then arranges for the event
44 loop to invoke at some later time the command registered
45 in that interpreter to handle background errors by the
46 \fBinterp bgerror\fR command, passing the captured values as
47 arguments.
48 The registered handler command is meant to report the exception
49 in an application-specific fashion. The handler command
50 receives two arguments, the result of the interp, and the
51 return options of the interp at the time the error occurred.
52 If the application registers no handler command, the default
53 handler command will attempt to call \fBbgerror\fR to report
54 the error. If an error condition arises while invoking the
55 handler command, then \fBTcl_BackgroundException\fR reports the
56 error itself by printing a message on the standard error file.
57 .PP
58 \fBTcl_BackgroundException\fR does not invoke the handler command immediately
59 because this could potentially interfere with scripts that are in process
60 at the time the error occurred.
61 Instead, it invokes the handler command later as an idle callback.
62 .PP
63 It is possible for many background exceptions to accumulate before
64 the handler command is invoked. When this happens, each of the exceptions
65 is processed in order. However, if the handler command returns a
66 break exception, then all remaining error reports for the
67 interpreter are skipped.
68 .PP
69 The \fBTcl_BackgroundError\fR routine is an older and simpler interface
70 useful when the exception code reported is \fBTCL_ERROR\fR. It is
71 equivalent to:
72 .PP
73 .CS
74 Tcl_BackgroundException(interp, TCL_ERROR);
75 .CE
76
77 .SH KEYWORDS
78 background, bgerror, error, interp