Misleading exception type in DiscordEmbedBuilder
Created by: jammy-dodgers
In the Embed builder, the AddField method can throw an ArgumentNullException for non-null but invalid arguments.
public DiscordEmbedBuilder AddField(string name, string value, bool inline = false)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(value))
throw new ArgumentNullException(nameof(value));
...
}
It would be more accurate to instead throw an ArgumentException when the value is invalid but non-null.
public DiscordEmbedBuilder AddField(string name, string value, bool inline = false)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (value == null)
throw new ArgumentNullException(nameof(value));
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentException($"{nameof(name)} cannot be whitespace.");
if (string.IsNullOrWhiteSpace(value))
throw new ArgumentException($"{nameof(value)} cannot be whitespace.");
...
}