-Improved JArray bad indexer message
This commit is contained in:
@@ -471,7 +471,7 @@ Parameter name: index");
|
||||
{
|
||||
JArray a = new JArray();
|
||||
a["badvalue"] = new JValue(3);
|
||||
}, @"Set JArray values with invalid key value: ""badvalue"". Array position index expected.");
|
||||
}, @"Set JArray values with invalid key value: ""badvalue"". Int32 array index expected.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -925,7 +925,7 @@ keyword such as type of business.""
|
||||
{
|
||||
JArray a = new JArray();
|
||||
Assert.AreEqual(null, a["purple"]);
|
||||
}, @"Accessed JArray values with invalid key value: ""purple"". Array position index expected.");
|
||||
}, @"Accessed JArray values with invalid key value: ""purple"". Int32 array index expected.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -236,7 +236,9 @@ namespace Newtonsoft.Json.Linq
|
||||
ValidationUtils.ArgumentNotNull(key, "o");
|
||||
|
||||
if (!(key is int))
|
||||
throw new ArgumentException("Accessed JArray values with invalid key value: {0}. Array position index expected.".FormatWith(CultureInfo.InvariantCulture, MiscellaneousUtils.ToString(key)));
|
||||
{
|
||||
throw new ArgumentException("Accessed JArray values with invalid key value: {0}. Int32 array index expected.".FormatWith(CultureInfo.InvariantCulture, MiscellaneousUtils.ToString(key)));
|
||||
}
|
||||
|
||||
return GetItem((int)key);
|
||||
}
|
||||
@@ -245,7 +247,9 @@ namespace Newtonsoft.Json.Linq
|
||||
ValidationUtils.ArgumentNotNull(key, "o");
|
||||
|
||||
if (!(key is int))
|
||||
throw new ArgumentException("Set JArray values with invalid key value: {0}. Array position index expected.".FormatWith(CultureInfo.InvariantCulture, MiscellaneousUtils.ToString(key)));
|
||||
{
|
||||
throw new ArgumentException("Set JArray values with invalid key value: {0}. Int32 array index expected.".FormatWith(CultureInfo.InvariantCulture, MiscellaneousUtils.ToString(key)));
|
||||
}
|
||||
|
||||
SetItem((int)key, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user