diff --git a/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs b/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs index c7ea6e13e8..6878468c68 100644 --- a/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs +++ b/Conduit/Conduit.Tests/TestHelpers/JsonTestHelpers.cs @@ -1,4 +1,7 @@ -using Newtonsoft.Json.Linq; +using System.Diagnostics; +using App.Metrics.Logging; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; namespace Conduit.Tests.TestHelpers; @@ -6,9 +9,21 @@ public static class JsonTestHelpers { public static T SubDoc(this string @this, string subDocKey) { - var obj = JObject.Parse(@this); - if (!obj.ContainsKey(subDocKey)) - throw new ArgumentException($"SubDoc '{subDocKey}' not found in JSON."); - return obj[subDocKey].ToObject(); + try + { + var obj = JObject.Parse(@this); + if (!obj.ContainsKey(subDocKey)) + throw new ArgumentException($"SubDoc '{subDocKey}' not found in JSON."); + return obj[subDocKey].ToObject(); + } + catch + { + Trace.WriteLine("TRACE There was a problem getting the subdoc of '{subDocKey}' from this JSON string: '{@this}"); + Debug.Print($"DEBUG There was a problem getting the subdoc of '{subDocKey}' from this JSON string: '{@this}"); + var logfactory = (ILoggerFactory)new LoggerFactory(); + var logger = new Logger(logfactory); + logger.LogError($"TRACE There was a problem getting the subdoc of '{subDocKey}' from this JSON string: '{@this}"); + throw; + } } }