Posted to tcl by oldlaptop at Sat Oct 03 18:38:58 GMT 2020view pretty
% proc foo {n} { if {$n >= 0} { return [::tcl::mathfunc::sqrt $n] } else { error "n must be nonnegative" } } % proc bar {n} { if {$n >= 0} { return [::tcl::mathfunc::sqrt $n] } else { return -code error "n must be nonnegative" } } % foo 2 1.4142135623730951 % bar 2 1.4142135623730951 % catch {foo -1} err opts 1 % dict get $opts -errorinfo n must be nonnegative while executing "error "n must be nonnegative" " (procedure "foo" line 1) invoked from within "foo -1" % catch {bar -1} err opts 1 % dict get $opts -errorinfo n must be nonnegative while executing "bar -1" %