Skip to content

Commit

Permalink
chore(quality): [eclipse-tractusx#841] simplify
Browse files Browse the repository at this point in the history
- inline method withProcessingError
- use the new helper methods from ProcessingErrorBuilder
  • Loading branch information
dsmf committed Jul 29, 2024
1 parent c57477c commit f0f30d0
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,20 @@ public static Tombstone from(final String catenaXId, final String endpointURL, f

public static Tombstone from(final String globalAssetId, final String endpointURL, final Throwable exception,
final Throwable[] suppressed, final int retryCount, final ProcessStep processStep) {
final ProcessingError processingError = withProcessingError(processStep, retryCount, exception.getMessage(),
suppressed);
return Tombstone.builder()
.endpointURL(endpointURL)
.catenaXId(globalAssetId)
.processingError(processingError)
.processingError(ProcessingError.builder()
.withProcessStep(processStep)
.withRetryCounterAndLastAttemptNow(retryCount)
.withErrorDetail(exception.getMessage())
.withRootCauses(getRootErrorMessages(suppressed))
.build())
.build();
}

private static ProcessingError withProcessingError(final ProcessStep processStep, final int retryCount,
final String message, final Throwable... suppressed) {
final List<String> rootCauses = Arrays.stream(suppressed).map(Tombstone::getRootErrorMessages).toList();

return ProcessingError.builder()
.withProcessStep(processStep)
.withRetryCounter(retryCount)
.withLastAttempt(ZonedDateTime.now(ZoneOffset.UTC))
.withErrorDetail(message)
.withRootCauses(rootCauses)
.build();
private static List<String> getRootErrorMessages(final Throwable... throwables) {
return Arrays.stream(throwables).map(Tombstone::getRootErrorMessages).toList();
}

/**
Expand Down

0 comments on commit f0f30d0

Please sign in to comment.