mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 21:24:58 +00:00
feat: ToStringJsonConverter rethrows the inner exception for TargetInvocationExceptions
This commit is contained in:
@@ -43,12 +43,19 @@ namespace ICD.Common.Utils.Json
|
|||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
MethodInfo parse = GetParseMethod(objectType);
|
MethodInfo parse = GetParseMethod(objectType);
|
||||||
if (parse != null)
|
if (parse == null)
|
||||||
return parse.Invoke(null, new[] {reader.Value});
|
throw new ArgumentException(
|
||||||
|
|
||||||
throw new ArgumentException(
|
|
||||||
string.Format("{0} does not have a 'static {0} Parse(string)' method.", objectType.Name),
|
string.Format("{0} does not have a 'static {0} Parse(string)' method.", objectType.Name),
|
||||||
"objectType");
|
"objectType");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return parse.Invoke(null, new[] { reader.Value });
|
||||||
|
}
|
||||||
|
catch (TargetInvocationException e)
|
||||||
|
{
|
||||||
|
throw e.InnerException;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user