TCL捕获忽略错误
args是从另一个TCL文件调用的脚本TCL捕获忽略错误,tcl,catch-block,Tcl,Catch Block,args是从另一个TCL文件调用的脚本 proc handler { args } { if { [catch {eval $args} errorMessage] } { _report_error "$errorMessage" } } proc是\u阈值\u百分比{thresholdValue}{ #这里有一些代码 如果{[string是双严格的$threshold]&&$threshold
proc handler { args } {
if { [catch {eval $args} errorMessage] } {
_report_error "$errorMessage"
}
}
proc是\u阈值\u百分比{thresholdValue}{
#这里有一些代码
如果{[string是双严格的$threshold]&&$threshold<0}{
错误“阈值${Threshold}%必须为正。”
}
返回1
}
返回0
}
没有拦网;s正常打印错误,程序带错误退出,但我需要处理错误消息并添加更多详细信息,catch block忽略错误并“正常”完成。catch经过了非常彻底的测试。它言行一致。我怀疑您给Tcl的指示与您想象的不完全一样;Tcl从不试图猜测你的意思。也许可以创建一个最小的例子来说明你认为哪里出了问题?
proc is_threshold_percent {thresholdValue } {
#some code here
if { [ string is double -strict $threshold ] && $threshold < 0 } {
error "Threshold ${threshold}% must be positive."
}
return 1
}
return 0
}