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

标签 error-handling try-catch tcl

嗨,我是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/

相关文章:

swift - 如何在 Swift 中正确获取作用域外的值 Do-Catch(使用 Try)

java - 尝试在 while 循环中使用 Try catch 直到用户正确回答而不输入无效数据(Java)

algorithm - 为 TCL 列表添加后缀

linux - tcl中如何改变目录文件的状态?

swift - 如何在 `NSURLSession` 超时时显示错误并终止应用程序?

excel - 错误1004遍历范围以获取最大日期

javascript try catch 在 firefox 中不能完全工作

c# - 尝试构建解决方案(对其进行调试)并收到错误消息,提示该.exe丢失

r - 我使用R进行回归分析时下标越界错误

c++ - 嵌入式 Tcl : Does Tcl autocomplete commands?