From 0663fe30df765032d0412ea9764bd5e17bb75bae Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Thu, 22 Apr 2021 15:09:05 -0500 Subject: [PATCH] Add cancellation reason codes to error logging --- .../textsecuregcm/storage/AccountsDynamoDb.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java index 1465aa7cb..653d6cbea 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsDynamoDb.java @@ -124,7 +124,7 @@ public class AccountsDynamoDb extends AbstractDynamoDbStore implements AccountSt } // this shouldn’t happen - throw new RuntimeException("could not create account"); + throw new RuntimeException("could not create account: " + extractCancellationReasonCodes(e)); } } catch (JsonProcessingException e) { throw new IllegalArgumentException(e); @@ -319,7 +319,9 @@ public class AccountsDynamoDb extends AbstractDynamoDbStore implements AccountSt @Override public void onError(Exception exception) { if (exception instanceof TransactionCanceledException) { - // account is already migrated + // account is likely already migrated + logger.warn("Error migrating account: {}", + extractCancellationReasonCodes((TransactionCanceledException) exception)); resultFuture.complete(false); } else { try { @@ -344,6 +346,12 @@ public class AccountsDynamoDb extends AbstractDynamoDbStore implements AccountSt } } + private static String extractCancellationReasonCodes(final TransactionCanceledException exception) { + return exception.getCancellationReasons().stream() + .map(CancellationReason::getCode) + .collect(Collectors.joining(", ")); + } + @VisibleForTesting static Account fromItem(Item item) { try {