1mNAME0m
       bgerror - Command invoked to process background errors

1mSYNOPSIS0m
       1mbgerror 4m22mmessage0m


1mDESCRIPTION0m
       The  1mbgerror  22mcommand  doesn't exist as built-in part of Tcl.  Instead,
       individual applications or users can define a 1mbgerror 22mcommand (e.g.  as
       a Tcl procedure) if they wish to handle background errors.

       A background error is one that occurs in an event handler or some other
       command that didn't originate with the application.  For example, if an
       error  occurs  while  executing a command specified with the 1mafter 22mcom-
       mand, 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 appli-
       cation  can  report  the error in whatever way it wishes.  When a back-
       ground error occurs, the unwinding ends in the Tcl library and there is
       no obvious way for Tcl to report the error.

       When  Tcl  detects  a  background error, it saves information about the
       error and invokes the 1mbgerror 22mcommand later as an idle  event  handler.
       Before invoking 1mbgerror22m, Tcl restores the 1merrorInfo 22mand 1merrorCode 22mvari-
       ables to their values at the time the error occurred, then  it  invokes
       1mbgerror  22mwith the error message as its only argument.  Tcl assumes that
       the application has implemented the 1mbgerror 22mcommand, and that the  com-
       mand  will  report the error in a way that makes sense for the applica-
       tion.  Tcl will ignore any result returned by the  1mbgerror  22mcommand  as
       long as no error is generated.

       If  another  Tcl  error occurs within the 1mbgerror 22mcommand (for example,
       because no 1mbgerror 22mcommand has been defined) then Tcl reports the error
       itself by writing a message to stderr.

       If  several  background  errors accumulate before 1mbgerror 22mis invoked to
       process them, 1mbgerror 22mwill be invoked once for each error, in the order
       they  occurred.   However,  if  1mbgerror 22mreturns with a break exception,
       then any remaining errors are skipped without calling 1mbgerror22m.

       Tcl has no default implementation for 1mbgerror22m. However, in applications
       using  Tk there is a default 1mbgerror 22mprocedure which posts a dialog box
       containing the error message and offers the user  a  chance  to  see  a
       stack  trace showing where the error occurred.  In addition to allowing
       the user to view the stack trace, the  dialog  provides  an  additional
       application configurable button which may be used, for example, to save
       the stack trace to a file.  By default, this is the behavior associated
       with that button.  This behavior can be redefined by setting the option
       database values 1m*ErrorDialog.function.text22m, to specify the caption  for
       the  function button, and 1m*ErrorDialog.function.command22m, to specify the
       command to be run.  The text of the stack trace is appended to the com-
       mand  when  it  is evaluated.  If either of these options is set to the
       empty string, then the additional button will not be displayed  in  the
       dialog.


1mSEE ALSO0m
       after(n), tclvars(n)


1mKEYWORDS0m
