beetlebug▾
/

thread errorproc

Sets or gives the proc that gets the errors of the threads.

thread::errorproc ?PROC?

Description

With PROC, the command thread::errorproc sets the proc that gets each error of a thread that no sender gets: an error of the script of thread::create, and of a script of thread::send -async with no variable. The proc runs in the thread that set it, in its event loop, with two arguments: the id of the thread and the error info. An empty PROC removes the proc, and the errors go to the output again. With no argument, the command gives the name of the proc.

The examples of this page run with --allow thread --allow event.

Arguments

ArgumentTypeDefaultDescription
PROCcommand namenoneThe proc of the errors, or an empty string.

Returns

An empty string, or the name of the proc.

Examples

% thread::errorproc

% proc ep {id info} {set ::got [lindex [split $info \n] 0]}
> thread::errorproc ep
> set t [thread::create]
> thread::send -async $t {error oops}
> vwait ::got
> set ::got
oops

% thread::errorproc ep
> thread::errorproc {}
> thread::errorproc

Errors

% thread::errorproc a b
wrong # args: should be "thread::errorproc ?proc?"
-errorcode TCL WRONGARGS

Facts

Capability
thread. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also