<html lang="en"> <head> <title>tkerror - GCL TK Manual</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GCL TK Manual"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Control.html#Control" title="Control"> <link rel="prev" href="tk.html#tk" title="tk"> <link rel="next" href="tkvars.html#tkvars" title="tkvars"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="tkerror"></a> <p> Next: <a rel="next" accesskey="n" href="tkvars.html#tkvars">tkvars</a>, Previous: <a rel="previous" accesskey="p" href="tk.html#tk">tk</a>, Up: <a rel="up" accesskey="u" href="Control.html#Control">Control</a> <hr> </div> <h3 class="section">3.20 tkerror</h3> <!-- @cartouche --> <p>tkerror \- Command invoked to process background errors <h4 class="unnumberedsubsec">Synopsis</h4> <p><b>tkerror </b><i>message</i> <!-- @end cartouche --> <h4 class="unnumberedsubsec">Description</h4> <p>The <b>tkerror</b> command doesn't exist as built-in part of Tk. Instead, individual applications or users can define a <b>tkerror</b> command (e.g. as a Tcl procedure) if they wish to handle background errors. <p>A background error is one that occurs in a command that didn't originate with the application. For example, if an error occurs while executing a command specified with a <b>bind</b><span class="roman"> of </span><b>after</b> command, then it is a background error. For a non-background error, the error can simply be returned up through nested Tcl command evaluations until it reaches the top-level code in the application; then the application can report the error in whatever way it wishes. When a background error occurs, the unwinding ends in the Tk library and there is no obvious way for Tk to report the error. <p>When Tk detects a background error, it invokes the <b>tkerror</b> command, passing it the error message as its only argument. Tk assumes that the application has implemented the <b>tkerror</b> command, and that the command will report the error in a way that makes sense for the application. Tk will ignore any result returned by the <b>tkerror</b> command. <p>If another Tcl error occurs within the <b>tkerror</b> command then Tk reports the error itself by writing a message to stderr. <p>The Tk script library includes a default <b>tkerror</b> procedure that posts a dialog box containing the error message and offers the user a chance to see a stack trace that shows where the error occurred. <h4 class="unnumberedsubsec">Keywords</h4> <p>background error, reporting </body></html>