VB   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了vb.net – 异常后继续代码大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道是否有办法让程序在抛出异常后继续.例如:
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 loging the error
  line 6  

Catch ex as Exception
   log(ex.toString)
End Try

谢谢.

如果你正在做一些你知道如何恢复或者不重要的事情,那么你应该在try / catch中用特定的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 loggin the error
  line 6  

Catch ex as Exception
   log(ex.toString)
End Try

大佬总结

以上是大佬教程为你收集整理的vb.net – 异常后继续代码全部内容,希望文章能够帮你解决vb.net – 异常后继续代码所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。