我想知道是否有办法让程序在抛出异常后继续执行。例如:
Try
line 1
line 2
line 3
line 4 ' (here the exception is thrown and jumps to the catch)
line 5 ' <-- I would like the program to continue its execution, logging the error
line 6
Catch ex as Exception
log(ex.tostring)
End Try
最佳答案
如果您正在做一些知道如何恢复或不重要的事情,则应该使用特定的 catch 将该行包装在 try/catch 中。 例如
Try
line 1
line 2
line 3
Try
line 4 ' (here the exception is throw and jumps to the catch)
Catch iox as IOException ' or whatever type is being thrown
'log it
End Try
line 5 ' <-- I would like the program to continue its execution after logging the error
line 6
Catch ex as Exception
log(ex.tostring)
End Try
关于vb.net - 抛出异常后如何继续运行代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3366635/