pro*_*eek 4 c# stylecop visual-studio-2010
我有一些引发异常的代码如下。
if (jobFinished)
{
...
} else
{
throw new Exception("The server Error ...")
}
Run Code Online (Sandbox Code Playgroud)
它可以编译/运行,没有问题,但是当我运行StyleCop时,出现了此错误消息,指出Exception不特定。
Error 10 CA2201 : Microsoft.Usage : Function(string, DirectoryInfo, string, string, string, out string)'
creates an exception of type 'Exception', an exception type that is not sufficiently
specific and should never be raised by user code. If this exception instance might be
thrown, use a different exception type.
Run Code Online (Sandbox Code Playgroud)
我遇到一些错误情况时只想抛出一个错误。如何做出足够明确的异常?
| 归档时间: |
|
| 查看次数: |
2137 次 |
| 最近记录: |