Go to main content

man pages section 3: Extended Library Functions, Volume 1

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

Tcl_BackgroundException (3tcl)

Name

Tcl_BackgroundException - report Tcl exception that occurred in background processing

Synopsis

#include <tcl.h>

Tcl_BackgroundException(interp, code)

Tcl_BackgroundError(interp)

Description

Tcl_BackgroundError(3tcl)   Tcl Library Procedures   Tcl_BackgroundError(3tcl)



______________________________________________________________________________

NAME
       Tcl_BackgroundException,  Tcl_BackgroundError  -  report  Tcl exception
       that occurred in background processing

SYNOPSIS
       #include <tcl.h>

       Tcl_BackgroundException(interp, code)

       Tcl_BackgroundError(interp)

ARGUMENTS
       Tcl_Interp *interp (in)          Interpreter  in  which  the  exception
                                        occurred.

       int code (in)                    The  exceptional  return  code  to  be
                                        reported.
______________________________________________________________________________


DESCRIPTION
       This procedure is typically invoked when a Tcl  exception  (any  return
       code  other  than TCL_OK) occurs during "background processing" such as
       executing an event handler.  When such an exception occurs, the  condi-
       tion  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 exception to
       the  user.   In these cases the code calls Tcl_BackgroundException with
       an interp argument identifying the interpreter in which  the  exception
       occurred,  and  a  code  argument  holding the return code value of the
       exception.  The state of the interpreter, including any  error  message
       in  the interpreter result, and the values of any entries in the return
       options dictionary, is  captured  and  saved.   Tcl_BackgroundException
       then  arranges for the event loop to invoke at some later time the com-
       mand registered in that interpreter to handle background errors by  the
       interp  bgerror command, passing the captured values as arguments.  The
       registered handler command is meant  to  report  the  exception  in  an
       application-specific  fashion.   The handler command receives two argu-
       ments, the result of the interp, and the return options of  the  interp
       at  the  time the error occurred.  If the application registers no han-
       dler command, the default handler command will attempt to call  bgerror
       to  report  the error.  If an error condition arises while invoking the
       handler command, then Tcl_BackgroundException reports the error  itself
       by printing a message on the standard error file.

       Tcl_BackgroundException 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 han-
       dler command later as an idle callback.

       It is possible for many background exceptions to accumulate before  the
       handler  command is invoked.  When this happens, each of the exceptions
       is processed in order.  However, if the handler command returns a break
       exception,  then  all  remaining  error reports for the interpreter are
       skipped.

       The Tcl_BackgroundError routine is an older and simpler interface  use-
       ful  when  the  exception code reported is TCL_ERROR.  It is equivalent
       to:

              Tcl_BackgroundException(interp, TCL_ERROR);


KEYWORDS
       background, bgerror, error, interp



ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+------------------+
       |ATTRIBUTE TYPE | ATTRIBUTE VALUE  |
       +---------------+------------------+
       |Availability   | runtime/tcl-8    |
       +---------------+------------------+
       |Stability      | Uncommitted      |
       +---------------+------------------+

NOTES
       Source code for open source software components in Oracle  Solaris  can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source was downloaded from  http://prdownloads.sourceforge.net/tcl/tcl-
       core8.6.7-src.tar.gz.

       Further information about this software can be found on the open source
       community website at https://www.tcl.tk/.



Tcl                                   7.5            Tcl_BackgroundError(3tcl)