Updated 2012-09-06 14:46:42 by oehhar
interp bgerror path ?cmdPrefix?

From http://www.tcl.tk/man/tcl8.5/TclCmd/interp.htm:

When an error happens in a situation where it cannot be reported directly up the stack (e.g. when processing events in an update or vwait call) the error is instead reported through the background error handling mechanism. Every interpreter has a background error handler registered; the default error handler arranges for the bgerror command in the interpreter's global namespace to be called, but other error handlers may be installed and process background errors in substantially different ways.

A background error handler consists of a non-empty list of words to which will be appended two further words at invocation time. The first word will be the error message string, and the second will a dictionary of return options (this is also the sort of information that can be obtained by trapping a normal error using catch of course.) The resulting list will then be executed in the interpreter's global namespace without further substitutions being performed.

MAKR 2007-11-26: There is no further hint at the interp page currently. I am interested in examples how this is supposed to be used. Especially as the bgerror man page encourages the move to this type of usage.

  Call bg error handler manually

HaO/MG 2012-09-05: Invoke bgerror from the program:
if { [catch {$cmd} err errdict] } {
catch {[interp bgerror ""] $err $errdict}

Category Command[Category Tcl syntax help]