gpt4 book ai didi

error-handling - 尝试忽略我的tcl命令中的错误

转载 作者:行者123 更新时间:2023-12-03 08:03:30 24 4
gpt4 key购买 nike

嗨,我是tcl的新手,我正在尝试在for循环中运行命令,尽管此命令执行其所需的操作,但是会引发异常,从而导致循环中断。因此,我需要忽略此命令产生的任何错误,并且每次在for循环中仍要尝试该命令。

for loop {
#do some stuff
$chassis exportPacketTrace $new_name -compress false 1 2 both #try this but ignore its error and continue
#do some stuff
}

请帮助我为这个问题提供一个好的解决方案

最佳答案

if {[catch {$chassis exportPacketTrace $new_name -compress false 1 2 both} issue]} {
puts "There is a failure and it is ignored"
puts "Reason for failure : $issue"
}

引用: catch

关于error-handling - 尝试忽略我的tcl命令中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44191068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com