使用 readlink 时的错误处理问题
problem with error handling when I use readlink
我在 运行 执行命令时遇到问题。
两种方法我都试过了,但没有得到想要的输出。
if{[catch {file readlink $ver}]}
然后输出为 "if{1} unknown command".
if{[catch [file readlink $ver]]}
然后它给出错误,它没有捕获错误。
我想让它捕获错误 & 运行 if
块的正文部分。
catch
块的正确语法:
if { [catch {file readlink $ver} errmsg] } {
puts $errmsg # will print the actual error
} else {
continue the body part!!!
}
我在 运行 执行命令时遇到问题。
两种方法我都试过了,但没有得到想要的输出。
if{[catch {file readlink $ver}]}
然后输出为 "if{1} unknown command".
if{[catch [file readlink $ver]]}
然后它给出错误,它没有捕获错误。
我想让它捕获错误 & 运行 if
块的正文部分。
catch
块的正确语法:
if { [catch {file readlink $ver} errmsg] } {
puts $errmsg # will print the actual error
} else {
continue the body part!!!
}