Throwing such general exceptions as Exception, SystemException, ApplicationException,
IndexOutOfRangeException, NullReferenceException, OutOfMemoryException and
ExecutionEngineException prevents calling methods from handling true, system-generated exceptions differently than application-generated
errors.
public void DoSomething(object obj)
{
if (obj == null)
{
throw new NullReferenceException("obj"); // Noncompliant
}
// ...
}
public void DoSomething(object obj)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
// ...
}