The constructors of ArgumentException and ArgumentNullException are inconsistent with each other, which results in their parameters being swapped here and there.pull/1139/head
@@ -75,7 +75,7 @@ namespace Discord | |||||
get => _fields; | get => _fields; | ||||
set | 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)); | if (value.Count > MaxFieldCount) throw new ArgumentException($"Field count must be less than or equal to {MaxFieldCount}.", nameof(Fields)); | ||||
_fields = value; | _fields = value; | ||||
} | } | ||||
@@ -45,10 +45,7 @@ namespace Discord | |||||
} | } | ||||
private static ArgumentException CreateNotEmptyException(string name, string msg) | 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 | //Numerics | ||||
public static void NotEqual(sbyte obj, sbyte value, string name, string msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } | public static void NotEqual(sbyte obj, sbyte value, string name, string msg = null) { if (obj == value) throw CreateNotEqualException(name, msg, value); } | ||||
@@ -19,7 +19,7 @@ namespace Discord | |||||
{ | { | ||||
// A Null or WhiteSpace token of any type is invalid. | // A Null or WhiteSpace token of any type is invalid. | ||||
if (string.IsNullOrWhiteSpace(token)) | 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) | switch (tokenType) | ||||
{ | { | ||||