【发布时间】:2009-10-26 01:44:20
【问题描述】:
我想在下面代码的空catch块中测试一些异常处理逻辑。
try
{
//Do Some stuff that throws a exception
//This is the code i need
}
catch (Exception)
{
//Handle things that inherits from Exception
}
catch
{
//Handle things that dont inherits from Exception
//Want to test this code
}
【问题讨论】:
-
缺少一个非常重要的注意事项是
doesnt inherit from Exception是可能的,但只能在 CLR1.0 平台上,或者在关闭WrapNonExceptionThrows 的情况下 - 这两种情况都很少见。
标签: .net exception exception-handling