Skip to content

Commit fd25bdf

Browse files
committed
fix: address PR review feedback
1 parent 06b54cd commit fd25bdf

4 files changed

Lines changed: 22 additions & 26 deletions

File tree

src/Exceptionless.Web/Api/Handlers/AdminHandler.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,16 @@ public async Task<Result<object>> Handle(GetAdminElasticsearchSnapshots message)
365365

366366
return new ElasticsearchSnapshotsResponse(successfulRepositoryNames, snapshots);
367367
}
368-
catch (Exception ex)
368+
catch (OperationCanceledException)
369+
{
370+
throw;
371+
}
372+
catch (InvalidOperationException ex)
373+
{
374+
_logger.LogError(ex, "Unable to retrieve snapshot information");
375+
return Result.Error("Unable to retrieve snapshot information.");
376+
}
377+
catch (TimeoutException ex)
369378
{
370379
_logger.LogError(ex, "Unable to retrieve snapshot information");
371380
return Result.Error("Unable to retrieve snapshot information.");

src/Exceptionless.Web/Api/Handlers/OrganizationHandler.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,6 @@ public async Task<Result<Invoice>> Handle(GetInvoice message)
231231
{
232232
_logger.LogCritical(ex, "Error getting invoice ({InvoiceId}): {Message}", invoiceId, ex.Message);
233233
}
234-
catch (Exception ex)
235-
{
236-
_logger.LogCritical(ex, "Unexpected error getting invoice ({InvoiceId}): {Message}", invoiceId, ex.Message);
237-
}
238234

239235
if (String.IsNullOrEmpty(stripeInvoice?.CustomerId))
240236
return Result.NotFound("Organization not found.");
@@ -546,11 +542,6 @@ await Task.WhenAll(
546542
_logger.LogCritical(ex, "Error occurred update billing plan: {Message}", ex.Message);
547543
return ChangePlanResult.FailWithMessage("An error occurred while changing plans. Please try again or contact support.");
548544
}
549-
catch (Exception ex)
550-
{
551-
_logger.LogCritical(ex, "An unexpected error occurred while trying to update your billing plan: {Message}", ex.Message);
552-
return ChangePlanResult.FailWithMessage("An error occurred while changing plans. Please try again.");
553-
}
554545

555546
return new ChangePlanResult { Success = true };
556547
}

src/Exceptionless.Web/Api/Infrastructure/JsonPatchValidation.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ public static IReadOnlySet<string> GetAffectedPropertyNames<T>(this JsonPatchDoc
110110
var policy = patch.SerializerOptions?.PropertyNamingPolicy;
111111
var affected = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
112112

113-
foreach (var op in patch.Operations)
113+
foreach (var pathSegment in patch.Operations.Select(op => NormalizePath(op.path).TrimStart('/')))
114114
{
115-
var pathSegment = NormalizePath(op.path).TrimStart('/');
116115
foreach (var prop in properties)
117116
{
118117
var jsonName = policy?.ConvertName(prop.Name) ?? prop.Name;
@@ -162,17 +161,14 @@ private static string GetMemberName<T>(Expression<Func<T, object?>> expression)
162161
if (body.ValueKind != JsonValueKind.Object)
163162
return null;
164163

165-
var ops = new JsonArray();
166-
foreach (var prop in body.EnumerateObject())
167-
{
168-
var op = new JsonObject
164+
var ops = new JsonArray(body.EnumerateObject()
165+
.Select(prop => new JsonObject
169166
{
170167
["op"] = "replace",
171168
["path"] = $"/{prop.Name}",
172169
["value"] = JsonNode.Parse(prop.Value.GetRawText())
173-
};
174-
ops.Add(op);
175-
}
170+
})
171+
.ToArray());
176172

177173
if (ops.Count == 0)
178174
return new JsonPatchDocument<T>([], options);

tests/Exceptionless.Tests/Controllers/OrganizationControllerTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ public async Task ChangePlanAsync_FreePlanCancelsActiveStripeSubscriptions()
12191219
public async Task ChangePlanAsync_StripeBillingClientThrows_ReturnsFailure()
12201220
{
12211221
// Arrange
1222-
StripeBillingClient.CreateCustomerException = new InvalidOperationException("Stripe unavailable");
1222+
StripeBillingClient.CreateCustomerException = new StripeException("Stripe unavailable");
12231223

12241224
// Act
12251225
var result = await WithBillingEnabledAsync(() =>
@@ -1239,7 +1239,7 @@ public async Task ChangePlanAsync_StripeBillingClientThrows_ReturnsFailure()
12391239
// Assert
12401240
Assert.NotNull(result);
12411241
Assert.False(result.Success);
1242-
Assert.Equal("An error occurred while changing plans. Please try again.", result.Message);
1242+
Assert.Equal("An error occurred while changing plans. Please try again or contact support.", result.Message);
12431243
Assert.Empty(StripeBillingClient.CreatedSubscriptionOptions);
12441244
}
12451245

@@ -1248,7 +1248,7 @@ public async Task ChangePlanAsync_NewCustomerSubscriptionFails_PreservesStripeCu
12481248
{
12491249
// Arrange
12501250
StripeBillingClient.CustomerToReturn = new Customer { Id = "cus_created" };
1251-
StripeBillingClient.CreateSubscriptionException = new InvalidOperationException("Stripe unavailable");
1251+
StripeBillingClient.CreateSubscriptionException = new StripeException("Stripe unavailable");
12521252

12531253
// Act
12541254
var result = await WithBillingEnabledAsync(() =>
@@ -1268,7 +1268,7 @@ public async Task ChangePlanAsync_NewCustomerSubscriptionFails_PreservesStripeCu
12681268
// Assert
12691269
Assert.NotNull(result);
12701270
Assert.False(result.Success);
1271-
Assert.Equal("An error occurred while changing plans. Please try again.", result.Message);
1271+
Assert.Equal("An error occurred while changing plans. Please try again or contact support.", result.Message);
12721272

12731273
var organization = await _organizationRepository.GetByIdAsync(SampleDataService.FREE_ORG_ID);
12741274
Assert.NotNull(organization);
@@ -1284,7 +1284,7 @@ public async Task ChangePlanAsync_ExistingCustomerSubscriptionFails_DoesNotPersi
12841284
// Arrange
12851285
await SetStripeCustomerIdAsync(SampleDataService.FREE_ORG_ID, "cus_existing");
12861286
StripeBillingClient.Subscriptions.Add(CreateStripeSubscription("sub_active", "si_active"));
1287-
StripeBillingClient.UpdateSubscriptionException = new InvalidOperationException("Stripe unavailable");
1287+
StripeBillingClient.UpdateSubscriptionException = new StripeException("Stripe unavailable");
12881288

12891289
// Act
12901290
var result = await WithBillingEnabledAsync(() =>
@@ -1304,7 +1304,7 @@ public async Task ChangePlanAsync_ExistingCustomerSubscriptionFails_DoesNotPersi
13041304
// Assert
13051305
Assert.NotNull(result);
13061306
Assert.False(result.Success);
1307-
Assert.Equal("An error occurred while changing plans. Please try again.", result.Message);
1307+
Assert.Equal("An error occurred while changing plans. Please try again or contact support.", result.Message);
13081308
Assert.NotEmpty(StripeBillingClient.UpdatedSubscriptions);
13091309

13101310
var organization = await _organizationRepository.GetByIdAsync(SampleDataService.FREE_ORG_ID);
@@ -1450,7 +1450,7 @@ public async Task GetInvoiceAsync_StripeInvoice_ReturnsMappedInvoice()
14501450
public Task GetInvoiceAsync_StripeBillingClientThrows_ReturnsNotFound()
14511451
{
14521452
// Arrange
1453-
StripeBillingClient.GetInvoiceException = new InvalidOperationException("Stripe unavailable");
1453+
StripeBillingClient.GetInvoiceException = new StripeException("Stripe unavailable");
14541454

14551455
// Act & Assert
14561456
return WithBillingEnabledAsync(() =>

0 commit comments

Comments
 (0)