From a55480f8e5f6f219bc8780c924af1de34fa2d226 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Fri, 12 Mar 2021 14:03:47 -0500 Subject: [PATCH] fix: Preserve stack trace when rethrowing inner exceptions --- ICD.Common.Utils/Json/ToStringJsonConverter.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ICD.Common.Utils/Json/ToStringJsonConverter.cs b/ICD.Common.Utils/Json/ToStringJsonConverter.cs index af6d176..67f161e 100644 --- a/ICD.Common.Utils/Json/ToStringJsonConverter.cs +++ b/ICD.Common.Utils/Json/ToStringJsonConverter.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using Crestron.SimplSharp.Reflection; #else using System.Reflection; +using System.Runtime.ExceptionServices; #endif using ICD.Common.Properties; using Newtonsoft.Json; @@ -54,7 +55,12 @@ namespace ICD.Common.Utils.Json } catch (TargetInvocationException e) { - throw e.InnerException; +#if SIMPLSHARP + throw e.InnerException ?? e; +#else + ExceptionDispatchInfo.Capture(e.InnerException ?? e).Throw(); + throw; +#endif } }