Browse Source

Fix swapped parameters in ArgumentException and ArgumentNullException cstrs

The constructors of ArgumentException and ArgumentNullException are inconsistent with each other, which results in their parameters being swapped here and there.
pull/1139/head
Chris Johnston 7 years ago
parent
commit
b5ff4c06eb
3 changed files with 3 additions and 6 deletions
  1. +1
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs
  2. +1
    -4
      src/Discord.Net.Core/Utils/Preconditions.cs
  3. +1
    -1
      src/Discord.Net.Core/Utils/TokenUtils.cs

+ 1
- 1
src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs View File

@@ -75,7 +75,7 @@ namespace Discord
get => _fields;
set
{
if (value == null) throw new ArgumentNullException("Cannot set an embed builder's fields collection to null", nameof(Fields));
if (value == null) throw new ArgumentNullException(nameof(Fields), "Cannot set an embed builder's fields collection to null");
if (value.Count > MaxFieldCount) throw new ArgumentException($"Field count must be less than or equal to {MaxFieldCount}.", nameof(Fields));
_fields = value;
}


+ 1
- 4
src/Discord.Net.Core/Utils/Preconditions.cs View File

@@ -45,10 +45,7 @@ namespace Discord
}

private static ArgumentException CreateNotEmptyException(string name, string msg)
{
if (msg == null) return new ArgumentException("Argument cannot be blank", name);
else return new ArgumentException(name, msg);
}
=> new ArgumentException(msg ?? "Argument cannot be blank.", name);

//Numerics
public static void NotEqual(sbyte obj, sbyte value, string name, string msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); }


+ 1
- 1
src/Discord.Net.Core/Utils/TokenUtils.cs View File

@@ -19,7 +19,7 @@ namespace Discord
{
// A Null or WhiteSpace token of any type is invalid.
if (string.IsNullOrWhiteSpace(token))
throw new ArgumentNullException("A token cannot be null, empty, or contain only whitespace.", nameof(token));
throw new ArgumentNullException(nameof(token), "A token cannot be null, empty, or contain only whitespace.");

switch (tokenType)
{


Loading…
Cancel
Save