Index: library/nx/nx.tcl =================================================================== diff -u -r6b570a0b4a22c8cc62e30454b8ca7610d1b4bc6c -rf5bba52ec263179be12a65a00a7d4f2282c445d2 --- library/nx/nx.tcl (.../nx.tcl) (revision 6b570a0b4a22c8cc62e30454b8ca7610d1b4bc6c) +++ library/nx/nx.tcl (.../nx.tcl) (revision f5bba52ec263179be12a65a00a7d4f2282c445d2) @@ -2508,12 +2508,9 @@ # Evaluate the command under catch to ensure reverse mapping # of "new" # - if {[catch [list ::apply [list {} $cmds $object]] errorMsg]} { - set errorCode $::errorCode - set errorOccured 1 - } else { - set errorOccured 0 - } + set errorOccured [catch \ + [list ::apply [list {} $cmds $object]] \ + result errorOptions] # # Remove the mapped "new" method, if it was added above @@ -2526,8 +2523,10 @@ # Report the error with message and code when necessary # if {$errorOccured} { - return -code error -errorcode $errorCode $errorMsg + dict incr errorOptions -level + dict unset errorOptions -errorinfo } + return -options $errorOptions $result } else { ::apply [list {} $cmds $object] Index: tests/contains.test =================================================================== diff -u -r4bc60e16c10fdbbb640b3019d4bdebdc469fdf55 -rf5bba52ec263179be12a65a00a7d4f2282c445d2 --- tests/contains.test (.../contains.test) (revision 4bc60e16c10fdbbb640b3019d4bdebdc469fdf55) +++ tests/contains.test (.../contains.test) (revision f5bba52ec263179be12a65a00a7d4f2282c445d2) @@ -145,6 +145,21 @@ C1 create c1 C1 create c1 +c1 destroy +C1 destroy + + +? {nx::Object create o} ::o +? {o contains { nx::Object create p}} ::o::p +? {catch {o contains { return -code error -errorcode {FOO bar baz} somethingwrong}} errorMsg} 1 +set ::errorinfo $::errorInfo +set ::errorcode $::errorCode +? {set ::errorMsg} {somethingwrong} +? {set ::errorinfo} {somethingwrong + while executing +"o contains { return -code error -errorcode {FOO bar baz} somethingwrong}"} +? {set ::errorcode} {FOO bar baz} + puts stderr "====EXIT [info script]" # # Local variables: