Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit eb31ea9

Browse files
committed
Handle when testing for HasCircularReferences throws Exception
1 parent b7ac626 commit eb31ea9

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/ServiceStack.Text/PlatformExtensions.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -745,24 +745,32 @@ public static Dictionary<string, object> ToSafePartialObjectDictionary<T>(this T
745745
{
746746
var valueType = entry.Value?.GetType();
747747

748-
if (valueType == null || !valueType.IsClass || valueType == typeof(string))
748+
try
749749
{
750-
to[entry.Key] = entry.Value;
751-
}
752-
else if (!TypeSerializer.HasCircularReferences(entry.Value))
753-
{
754-
if (entry.Value is IEnumerable enumerable)
750+
if (valueType == null || !valueType.IsClass || valueType == typeof(string))
755751
{
756752
to[entry.Key] = entry.Value;
757753
}
754+
else if (!TypeSerializer.HasCircularReferences(entry.Value))
755+
{
756+
if (entry.Value is IEnumerable enumerable)
757+
{
758+
to[entry.Key] = entry.Value;
759+
}
760+
else
761+
{
762+
to[entry.Key] = entry.Value.ToSafePartialObjectDictionary();
763+
}
764+
}
758765
else
759766
{
760-
to[entry.Key] = entry.Value.ToSafePartialObjectDictionary();
767+
to[entry.Key] = entry.Value.ToString();
761768
}
769+
762770
}
763-
else
771+
catch (Exception ignore)
764772
{
765-
to[entry.Key] = entry.Value.ToString();
773+
Tracer.Instance.WriteDebug($"Could not retrieve value from '{valueType?.GetType().Name}': ${ignore.Message}");
766774
}
767775
}
768776
}

0 commit comments

Comments
 (0)