mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-13 19:55:02 +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)
|
||||
{
|
||||
MethodInfo parse = GetParseMethod(objectType);
|
||||
if (parse != null)
|
||||
return parse.Invoke(null, new[] {reader.Value});
|
||||
|
||||
throw new ArgumentException(
|
||||
if (parse == null)
|
||||
throw new ArgumentException(
|
||||
string.Format("{0} does not have a 'static {0} Parse(string)' method.", objectType.Name),
|
||||
"objectType");
|
||||
|
||||
try
|
||||
{
|
||||
return parse.Invoke(null, new[] { reader.Value });
|
||||
}
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
throw e.InnerException;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user