-Added Path to JsonReaderException/JsonSerializationException messages

-Added JsonException
-Fixed all Exceptions thrown to be more specific
This commit is contained in:
James Newton-King
2012-04-21 17:25:44 +12:00
parent c120bf530d
commit a7bddf989f
69 changed files with 1400 additions and 1161 deletions
@@ -376,7 +376,7 @@ namespace Newtonsoft.Json.Utilities
return EnsureTypeAssignable(ToValue((INullable)initialValue), initialType, targetType);
#endif
throw new Exception("Can not convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, initialType, targetType));
throw new InvalidOperationException("Can not convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, initialType, targetType));
}
#endregion
@@ -445,7 +445,7 @@ namespace Newtonsoft.Json.Utilities
return null;
}
throw new Exception("Could not cast or convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, (initialType != null) ? initialType.ToString() : "{null}", targetType));
throw new ArgumentException("Could not cast or convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, (initialType != null) ? initialType.ToString() : "{null}", targetType));
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
@@ -464,7 +464,7 @@ namespace Newtonsoft.Json.Utilities
else if (nullableValue is SqlDateTime)
return ToValue((SqlDateTime)nullableValue);
throw new Exception("Unsupported INullable type: {0}".FormatWith(CultureInfo.InvariantCulture, nullableValue.GetType()));
throw new ArgumentException("Unsupported INullable type: {0}".FormatWith(CultureInfo.InvariantCulture, nullableValue.GetType()));
}
#endif