Here is a code example:
set my_ref {$undefined_array(some_key)}
set my_val [subst $my_ref]
which returns:
can't read "undefined_array(some_key)": no such variable
while executing
"subst $my_ref"
According to http://wiki.tcl.tk/1501
Looks like there is no way to catch this right now
When
substattempts to perform substitutions on the text you gave it, it needs an existing variable with a matching name. If no such variable exists,substthrows aTCL LOOKUP VARNAMEexception.How to catch that? You can catch the exception after
substhas failed as usual, withcatchortry. The discussion you referred to was AFAICT about catching exceptions beforesubsthas failed, which I believe still isn't possible.ETA:
Proof-of-concept for my "discriminating try" comment. This code has tons of potential problems but at least demonstrates basically how it could be done. In the example, the handler reacts by creating a variable that has its own name in uppercase as value.