Skip to content

Commit b667262

Browse files
reason format fix
1 parent e056b89 commit b667262

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

OptimizelySDK.Tests/CmabTests/DecisionServiceCmabTest.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void TestGetVariationWithCmabExperimentReturnsVariation()
105105

106106
var reasons = result.DecisionReasons.ToReport(true);
107107
var expectedMessage =
108-
$"CMAB decision fetched for user [{TEST_USER_ID}] in experiment [{TEST_EXPERIMENT_KEY}].";
108+
$"CMAB decision fetched for user {TEST_USER_ID} in experiment {TEST_EXPERIMENT_KEY}.";
109109
Assert.Contains(expectedMessage, reasons);
110110

111111
_cmabServiceMock.Verify(c => c.GetDecision(
@@ -187,12 +187,11 @@ public void TestGetVariationWithCmabExperimentServiceError()
187187
Assert.IsTrue(result.ResultObject.CmabError);
188188

189189
var reasonsList = result.DecisionReasons.ToReport(true);
190+
190191
Assert.IsTrue(reasonsList.Exists(reason =>
191192
reason.Contains(
192-
$"Failed to fetch CMAB decision for experiment [{TEST_EXPERIMENT_KEY}].")),
193+
$"Failed to fetch CMAB decision for experiment {TEST_EXPERIMENT_KEY}.")),
193194
$"Decision reasons should include CMAB fetch failure. Actual reasons: {string.Join(", ", reasonsList)}");
194-
Assert.IsTrue(reasonsList.Exists(reason => reason.Contains("Error: CMAB service error")),
195-
$"Decision reasons should include CMAB service error text. Actual reasons: {string.Join(", ", reasonsList)}");
196195

197196
_cmabServiceMock.Verify(c => c.GetDecision(
198197
It.IsAny<ProjectConfig>(),
@@ -313,7 +312,7 @@ public void TestGetVariationWithCmabExperimentCacheHit()
313312

314313
var reasons = result2.DecisionReasons.ToReport(true);
315314
var expectedMessage =
316-
$"CMAB decision fetched for user [{TEST_USER_ID}] in experiment [{TEST_EXPERIMENT_KEY}].";
315+
$"CMAB decision fetched for user {TEST_USER_ID} in experiment {TEST_EXPERIMENT_KEY}.";
317316
Assert.Contains(expectedMessage, reasons);
318317
}
319318

OptimizelySDK/Bucketing/DecisionService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,11 @@ OptimizelyDecideOption[] options
338338
return Result<VariationDecisionResult>.NewResult(
339339
new VariationDecisionResult(variation, cmabDecision.CmabUuid), reasons);
340340
}
341-
catch (Exception ex)
341+
catch (Exception)
342342
{
343343
var message = string.Format(CmabConstants.CMAB_FETCH_FAILED, experiment.Key);
344-
Logger.Log(LogLevel.ERROR, reasons.AddInfo($"{message} Error: {ex.Message}"));
344+
reasons.AddError(message);
345+
Logger.Log(LogLevel.ERROR, message);
345346
return Result<VariationDecisionResult>.NewResult(
346347
new VariationDecisionResult(null, null, true), reasons);
347348
}

OptimizelySDK/Cmab/CmabConstants.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ internal static class CmabConstants
3232
"User [{0}] not in CMAB experiment [{1}] due to traffic allocation.";
3333

3434
public const string CMAB_FETCH_FAILED =
35-
"Failed to fetch CMAB decision for experiment [{0}].";
35+
"Failed to fetch CMAB decision for experiment {0}.";
3636

3737
public const string CMAB_DECISION_FETCHED =
38-
"CMAB decision fetched for user [{0}] in experiment [{1}].";
39-
40-
public const string CMAB_EXPERIMENT_NOT_PROPERLY_CONFIGURED =
41-
"CMAB experiment [{0}] is not properly configured.";
38+
"CMAB decision fetched for user {0} in experiment {1}.";
4239

4340
public static readonly TimeSpan MAX_TIMEOUT = TimeSpan.FromSeconds(10);
4441
public static readonly TimeSpan DEFAULT_CACHE_TTL = TimeSpan.FromMinutes(10);

0 commit comments

Comments
 (0)