mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 03:57:32 +00:00
feat: ToStringJsonConverter rethrows the inner exception for TargetInvocationExceptions
This commit is contained in:
parent
f8c88630fc
commit
63b590a9ea
1 changed files with 11 additions and 4 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue