diff --git a/OptimizelySDK.Net35/OptimizelySDK.Net35.csproj b/OptimizelySDK.Net35/OptimizelySDK.Net35.csproj
index 2af5ec2a..90606598 100644
--- a/OptimizelySDK.Net35/OptimizelySDK.Net35.csproj
+++ b/OptimizelySDK.Net35/OptimizelySDK.Net35.csproj
@@ -172,10 +172,13 @@
Utils\ControlAttributes.cs
-
+
+ Utils\ExceptionExtensions.cs
+
+
Utils\ConditionParser.cs
-
+
Utils\AttributeMatchTypes.cs
diff --git a/OptimizelySDK.Net40/OptimizelySDK.Net40.csproj b/OptimizelySDK.Net40/OptimizelySDK.Net40.csproj
index 9652d8da..05616710 100644
--- a/OptimizelySDK.Net40/OptimizelySDK.Net40.csproj
+++ b/OptimizelySDK.Net40/OptimizelySDK.Net40.csproj
@@ -176,7 +176,10 @@
Utils\ControlAttributes.cs
-
+
+ Utils\ExceptionExtensions.cs
+
+
Utils\AttributeMatchTypes.cs
diff --git a/OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj b/OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj
index b705269a..f1501d9a 100644
--- a/OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj
+++ b/OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj
@@ -55,10 +55,11 @@
-
-
-
-
+
+
+
+
+
diff --git a/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj b/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj
index 6b112446..4a90e741 100644
--- a/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj
+++ b/OptimizelySDK.Tests/OptimizelySDK.Tests.csproj
@@ -87,6 +87,7 @@
+
diff --git a/OptimizelySDK.Tests/UtilsTests/ExceptionExtensionsTest.cs b/OptimizelySDK.Tests/UtilsTests/ExceptionExtensionsTest.cs
new file mode 100644
index 00000000..9eb1020b
--- /dev/null
+++ b/OptimizelySDK.Tests/UtilsTests/ExceptionExtensionsTest.cs
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2019, Optimizely
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using NUnit.Framework;
+using OptimizelySDK.Utils;
+using System;
+
+namespace OptimizelySDK.Tests.UtilsTests
+{
+ public class ExceptionExtensionsTest
+ {
+ [Test]
+ public void TestGetAllMessagesReturnsAllInnerExceptionMessages()
+ {
+ var exception = new Exception("Outer exception.", new Exception("Inner exception.", new Exception("Second level inner exception.")));
+ var expectedMessage = "Outer exception.\nInner exception.\nSecond level inner exception.";
+
+ Assert.AreEqual(expectedMessage, exception.GetAllMessages());
+ }
+ }
+}
diff --git a/OptimizelySDK/Event/Dispatcher/HttpClientEventDispatcher45.cs b/OptimizelySDK/Event/Dispatcher/HttpClientEventDispatcher45.cs
index 4498e7aa..8dbbfbbb 100644
--- a/OptimizelySDK/Event/Dispatcher/HttpClientEventDispatcher45.cs
+++ b/OptimizelySDK/Event/Dispatcher/HttpClientEventDispatcher45.cs
@@ -1,5 +1,5 @@
/*
- * Copyright 2017, Optimizely
+ * Copyright 2017, 2019, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
#if !NET35 && !NET40
using OptimizelySDK.Logger;
+using OptimizelySDK.Utils;
using System;
using System.Net.Http;
using System.Threading.Tasks;
@@ -63,7 +64,7 @@ private async void DispatchEventAsync(LogEvent logEvent)
}
catch (Exception ex)
{
- Logger.Log(LogLevel.ERROR, string.Format("Error Dispatching Event: {0}", ex.Message));
+ Logger.Log(LogLevel.ERROR, string.Format("Error Dispatching Event: {0}", ex.GetAllMessages()));
}
}
diff --git a/OptimizelySDK/OptimizelySDK.csproj b/OptimizelySDK/OptimizelySDK.csproj
index 8a83baa2..bc0ab682 100644
--- a/OptimizelySDK/OptimizelySDK.csproj
+++ b/OptimizelySDK/OptimizelySDK.csproj
@@ -113,6 +113,7 @@
+
diff --git a/OptimizelySDK/Utils/ExceptionExtensions.cs b/OptimizelySDK/Utils/ExceptionExtensions.cs
new file mode 100644
index 00000000..45c04e45
--- /dev/null
+++ b/OptimizelySDK/Utils/ExceptionExtensions.cs
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2019, Optimizely
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace OptimizelySDK.Utils
+{
+ public static class ExceptionExtensions
+ {
+ public static string GetAllMessages(this Exception exception, string separator = "\n")
+ {
+ if (exception.InnerException == null)
+ return exception.Message;
+
+ return (string.IsNullOrEmpty(exception.Message) ? "" : string.Format("{0}{1}", exception.Message, separator))
+ + GetAllMessages(exception.InnerException, separator);
+ }
+ }
+}