I wrote a simple replacement of Tcl's catch command. The rationale of
this script is that when [::rivet::abort_page] interrupts a script
execution by returning a Tcl error regular ::catch construct may hide
the abort condition unless the error code explicitly tested and the in
case the error thrown again. I thought we could offer the programmer a
rivet based implementation (actually a trivial wrapper in this
preliminary form) named ::rivet::catch which has the same definition as
the core command. This procedure passes execution to [::catch] if an
error did not occur as a consequence of calling either
::rivet::abort_page or [exit] (the exit core command is now shadowed by
a rivet implementation)
Here is the command. Can anyone spot trivial errors or possible
optimizations? I tested it with a script with different arguments and it
seems to be OK
namespace eval ::rivet {
proc catch {script args} {
set catch_cmd [list ::catch $script]
if {[llength $args] >= 1} {
upvar [lindex $args 0] errvar
lappend catch_cmd errvar
}
if {[llength $args] >= 2} {
upvar [lindex $args 1] catchopt
lappend catch_cmd catchopt
}
set catch_ret [eval $catch_cmd]
if {$catch_ret && [::rivet::abort_page -aborting]} {
return -code error -errorcode ABORTPAGE
} else {
return $catch_ret
}
}
}
-- Massimo
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]