代码:
catch(Exception ex)
{
if (ex is WebException)
{
wccfg.failedUrls++; // i think you forgot this
return csFiles;
}
else
{
throw new Exception("");
wccfg.failedUrls++;
return csFiles;
}
}
Run Code Online (Sandbox Code Playgroud)
在第二个wccfg(另一个类)上,我看到绿线表示检测到无法访问的代码.我应该将此行移到抛出新的异常行吗?
因为一旦你:
throw new Exception("");
Run Code Online (Sandbox Code Playgroud)
在该点之后没有其他代码将被执行.
是的 你需要一个return或一个throw,你不能两者兼得.
也没有理由测试Exception类型使用if块的内容,因为您可以使用多个catch语句来执行此操作.
| 归档时间: |
|
| 查看次数: |
575 次 |
| 最近记录: |