Skip to content

Commit 8663a46

Browse files
fix: logs
1 parent 2c3687d commit 8663a46

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/integration-test/java/com/commercetools/sync/integration/commons/utils/CategoryITUtils.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@
3838
import java.util.stream.Collectors;
3939
import javax.annotation.Nonnull;
4040
import javax.annotation.Nullable;
41+
import org.slf4j.Logger;
42+
import org.slf4j.LoggerFactory;
4143

4244
public final class CategoryITUtils {
45+
private static final Logger logger = LoggerFactory.getLogger(CategoryITUtils.class);
46+
4347
public static final String OLD_CATEGORY_CUSTOM_TYPE_KEY = "oldCategoryCustomTypeKey";
4448
public static final String OLD_CATEGORY_CUSTOM_TYPE_NAME = "old_type_name";
4549

@@ -299,8 +303,13 @@ public static void deleteAllCategories(@Nonnull final ProjectApiRoot ctpClient)
299303
} catch (NotFoundException e) {
300304
// Already deleted, mark as deleted
301305
deletedIds.add(categoryId);
302-
} catch (Exception e) {
303-
// Ignore - may have been deleted by parent cascade
306+
} catch (RuntimeException e) {
307+
// May have been deleted by parent cascade - this is expected behavior
308+
logger.debug(
309+
"Could not delete category ID: {}, key: {}. Reason: {}",
310+
categoryId,
311+
category.getKey(),
312+
e.getMessage());
304313
}
305314
}
306315
});
@@ -345,12 +354,18 @@ public static void deleteCategoriesBySlug(
345354
.execute()
346355
.toCompletableFuture()
347356
.join();
348-
} catch (Exception e) {
349-
// Ignore - already deleted or cascade deleted
357+
} catch (RuntimeException e) {
358+
// Expected: already deleted, cascade deleted, or version conflict
359+
logger.debug(
360+
"Could not delete category with slug '{}', ID: {}. Reason: {}",
361+
slug,
362+
cat.getId(),
363+
e.getMessage());
350364
}
351365
});
352-
} catch (Exception e) {
353-
// Ignore - slug doesn't exist
366+
} catch (RuntimeException e) {
367+
// Expected: slug doesn't exist or query failed
368+
logger.debug("Could not query categories with slug '{}'. Reason: {}", slug, e.getMessage());
354369
}
355370
}
356371
}

0 commit comments

Comments
 (0)