Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Error handling 尝试并忽略我的tcl命令中的错误_Error Handling_Try Catch_Tcl - Fatal编程技术网

Error handling 尝试并忽略我的tcl命令中的错误

Error handling 尝试并忽略我的tcl命令中的错误,error-handling,try-catch,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 so

您好,我是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”就可以了+我已经猜出来了。是的,使用“catch”就可以了+从我这里得到1。