Why no ArgumentEmptyException in .NET ?
- by Andrei Rinea
I am beginning to think I am doing something wrong. I mean they did place System.String.IsNullOrWhitespace finally but no ArgumentEmptyException class.
public FilterItem(string name, IEnumerable<string> extensions)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name");
}
if (extensions == null)
{
throw new ArgumentNullException("extensions");
}
if (extensions.Count() == 0)
{
throw new ArgumentOutOfRangeException("extensions");
}
this.Name = name;
this.Extensions = extensions;
}
throwing an ArgumentOutOfRangeException feels unnatural. Also an instance of ArgumentException is too general in my opinion.
It's easy to me to create a new exception class call it this way and have it over with. What bugs me is that it's not in the BCL/FCL and I am beginning to think there's a good reason not to have it.
Should there be one?