| 1 |
'\" |
| 2 |
'\" See the file "license.terms" for information on usage and redistribution |
| 3 |
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 4 |
'\" |
| 5 |
.TH Tcl_Panic 3 8.4 Tcl "Tcl Library Procedures" |
| 6 |
.so man.macros |
| 7 |
.BS |
| 8 |
'\" Note: do not modify the .SH NAME line immediately below! |
| 9 |
.SH NAME |
| 10 |
Tcl_Panic, Tcl_PanicVA, Tcl_SetPanicProc \- report fatal error and abort |
| 11 |
.SH SYNOPSIS |
| 12 |
.nf |
| 13 |
\fB#include <tcl.h>\fR |
| 14 |
.sp |
| 15 |
void |
| 16 |
\fBTcl_Panic\fR(\fIformat\fR, \fIarg\fR, \fIarg\fR, \fI...\fR) |
| 17 |
.sp |
| 18 |
void |
| 19 |
\fBTcl_PanicVA\fR(\fIformat\fR, \fIargList\fR) |
| 20 |
.sp |
| 21 |
void |
| 22 |
\fBTcl_SetPanicProc\fR(\fIpanicProc\fR) |
| 23 |
.sp |
| 24 |
.SH ARGUMENTS |
| 25 |
.AS Tcl_PanicProc *panicProc |
| 26 |
.AP "const char*" format in |
| 27 |
A printf-style format string. |
| 28 |
.AP "" arg in |
| 29 |
Arguments matching the format string. |
| 30 |
.AP va_list argList in |
| 31 |
An argument list of arguments matching the format string. |
| 32 |
Must have been initialized using \fBva_start\fR, |
| 33 |
and cleared using \fBva_end\fR. |
| 34 |
.AP Tcl_PanicProc *panicProc in |
| 35 |
Procedure to report fatal error message and abort. |
| 36 |
.BE |
| 37 |
.SH DESCRIPTION |
| 38 |
.PP |
| 39 |
When the Tcl library detects that its internal data structures are in an |
| 40 |
inconsistent state, or that its C procedures have been called in a |
| 41 |
manner inconsistent with their documentation, it calls \fBTcl_Panic\fR |
| 42 |
to display a message describing the error and abort the process. The |
| 43 |
\fIformat\fR argument is a format string describing how to format the |
| 44 |
remaining arguments \fIarg\fR into an error message, according to the |
| 45 |
same formatting rules used by the \fBprintf\fR family of functions. The |
| 46 |
same formatting rules are also used by the built-in Tcl command |
| 47 |
\fBformat\fR. |
| 48 |
.PP |
| 49 |
In a freshly loaded Tcl library, \fBTcl_Panic\fR prints the formatted |
| 50 |
error message to the standard error file of the process, and then |
| 51 |
calls \fBabort\fR to terminate the process. \fBTcl_Panic\fR does not |
| 52 |
return. On Windows, when a debugger is running, the formatted error |
| 53 |
message is sent to the debugger instead. If the windows executable |
| 54 |
does not have a stderr channel (e.g. \fBwish.exe\fR), then a |
| 55 |
system dialog box is used to display the panic message. |
| 56 |
.PP |
| 57 |
\fBTcl_SetPanicProc\fR may be used to modify the behavior of |
| 58 |
\fBTcl_Panic\fR. The \fIpanicProc\fR argument should match the |
| 59 |
type \fBTcl_PanicProc\fR: |
| 60 |
.PP |
| 61 |
.CS |
| 62 |
typedef void \fBTcl_PanicProc\fR( |
| 63 |
const char *\fBformat\fR, |
| 64 |
\fBarg\fR, \fBarg\fR,...); |
| 65 |
.CE |
| 66 |
.PP |
| 67 |
After \fBTcl_SetPanicProc\fR returns, any future calls to |
| 68 |
\fBTcl_Panic\fR will call \fIpanicProc\fR, passing along the |
| 69 |
\fIformat\fR and \fIarg\fR arguments. \fIpanicProc\fR should avoid |
| 70 |
making calls into the Tcl library, or into other libraries that may |
| 71 |
call the Tcl library, since the original call to \fBTcl_Panic\fR |
| 72 |
indicates the Tcl library is not in a state of reliable operation. |
| 73 |
.PP |
| 74 |
The typical use of \fBTcl_SetPanicProc\fR arranges for the error message |
| 75 |
to be displayed or reported in a manner more suitable for the |
| 76 |
application or the platform. |
| 77 |
.PP |
| 78 |
Although the primary callers of \fBTcl_Panic\fR are the procedures of |
| 79 |
the Tcl library, \fBTcl_Panic\fR is a public function and may be called |
| 80 |
by any extension or application that wishes to abort the process and |
| 81 |
have a panic message displayed the same way that panic messages from Tcl |
| 82 |
will be displayed. |
| 83 |
.PP |
| 84 |
\fBTcl_PanicVA\fR is the same as \fBTcl_Panic\fR except that instead of |
| 85 |
taking a variable number of arguments it takes an argument list. |
| 86 |
.SH "SEE ALSO" |
| 87 |
abort(3), printf(3), exec(n), format(n) |
| 88 |
.SH KEYWORDS |
| 89 |
abort, fatal, error |