I have code that throws an exception as follows.
if (jobFinished)
{
...
} else
{
throw new Exception("The server Error ...")
}
It compiles / starts without problems, but when I start StyleCop, I got this error message: Exception is not specific.
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.
I just want to throw an error when I come across some error conditions. How can I make a rather specific exception?
source
share