Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions OptimizelySDK.Net35/OptimizelySDK.Net35.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,13 @@
<Compile Include="..\OptimizelySDK\Utils\ControlAttributes.cs">
<Link>Utils\ControlAttributes.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Utils\ConditionParser.cs">
<Compile Include="..\OptimizelySDK\Utils\ExceptionExtensions.cs">
<Link>Utils\ExceptionExtensions.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Utils\ConditionParser.cs">
<Link>Utils\ConditionParser.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Utils\AttributeMatchTypes.cs">
<Compile Include="..\OptimizelySDK\Utils\AttributeMatchTypes.cs">
<Link>Utils\AttributeMatchTypes.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
5 changes: 4 additions & 1 deletion OptimizelySDK.Net40/OptimizelySDK.Net40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@
<Compile Include="..\OptimizelySDK\Utils\ControlAttributes.cs">
<Link>Utils\ControlAttributes.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Utils\AttributeMatchTypes.cs">
<Compile Include="..\OptimizelySDK\Utils\ExceptionExtensions.cs">
<Link>Utils\ExceptionExtensions.cs</Link>
</Compile>
<Compile Include="..\OptimizelySDK\Utils\AttributeMatchTypes.cs">
<Link>Utils\AttributeMatchTypes.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@
<Compile Include="..\OptimizelySDK\Utils\Validator.cs" />
<Compile Include="..\OptimizelySDK\Utils\ConfigParser.cs" />
<Compile Include="..\OptimizelySDK\Utils\Schema.cs" />
<Compile Include="..\OptimizelySDK\Utils\ControlAttributes.cs" />
<Compile Include="..\OptimizelySDK\Utils\ExperimentUtils.cs" />
<Compile Include="..\OptimizelySDK\Utils\ConditionParser.cs" />
<Compile Include="..\OptimizelySDK\Utils\AttributeMatchTypes.cs" />
<Compile Include="..\OptimizelySDK\Utils\ControlAttributes.cs" />
<Compile Include="..\OptimizelySDK\Utils\ExceptionExtensions.cs" />
<Compile Include="..\OptimizelySDK\Utils\ExperimentUtils.cs" />
<Compile Include="..\OptimizelySDK\Utils\ConditionParser.cs" />
<Compile Include="..\OptimizelySDK\Utils\AttributeMatchTypes.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\Bucketer.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\Decision.cs" />
<Compile Include="..\OptimizelySDK\Bucketing\DecisionService.cs" />
Expand Down
1 change: 1 addition & 0 deletions OptimizelySDK.Tests/OptimizelySDK.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Compile Include="ProjectConfigTest.cs" />
<Compile Include="UtilsTests\ConditionParserTest.cs" />
<Compile Include="UtilsTests\EventTagUtilsTest.cs" />
<Compile Include="UtilsTests\ExceptionExtensionsTest.cs" />
<Compile Include="UtilsTests\ExperimentUtilsTest.cs" />
<Compile Include="UtilsTests\PrivateObject.cs" />
<Compile Include="UtilsTests\ValidatorTest.cs" />
Expand Down
34 changes: 34 additions & 0 deletions OptimizelySDK.Tests/UtilsTests/ExceptionExtensionsTest.cs
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
5 changes: 3 additions & 2 deletions OptimizelySDK/Event/Dispatcher/HttpClientEventDispatcher45.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,6 +15,7 @@
*/
#if !NET35 && !NET40
using OptimizelySDK.Logger;
using OptimizelySDK.Utils;
using System;
using System.Net.Http;
using System.Threading.Tasks;
Expand Down Expand Up @@ -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()));
}
}

Expand Down
1 change: 1 addition & 0 deletions OptimizelySDK/OptimizelySDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<Compile Include="Bucketing\UserProfileUtil.cs" />
<Compile Include="Utils\ExperimentUtils.cs" />
<Compile Include="Utils\ControlAttributes.cs" />
<Compile Include="Utils\ExceptionExtensions.cs" />
<Compile Include="Utils\Validator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\ConfigParser.cs" />
Expand Down
32 changes: 32 additions & 0 deletions OptimizelySDK/Utils/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.

{
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);
}
}
}