mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 03:45:57 +00:00
[AB-323] improving logging when using whenComplete
This commit is contained in:
@@ -48,12 +48,11 @@ public class WarnEntryConverter {
|
||||
allFutures.add(warnedMemberFuture);
|
||||
});
|
||||
CompletableFuture<List<WarnEntry>> future = new CompletableFuture<>();
|
||||
FutureUtils.toSingleFutureGeneric(allFutures).whenComplete((unused, throwable) -> {
|
||||
try {
|
||||
future.complete(self.loadFullWarnEntries(loadedWarnings));
|
||||
} catch (Exception exception) {
|
||||
future.completeExceptionally(exception);
|
||||
}
|
||||
FutureUtils.toSingleFutureGeneric(allFutures)
|
||||
.whenComplete((unused, throwable) -> future.complete(self.loadFullWarnEntries(loadedWarnings)))
|
||||
.exceptionally(throwable -> {
|
||||
future.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
@@ -90,6 +90,9 @@ public class BanServiceBean implements BanService {
|
||||
returningFuture.completeExceptionally(throwable1);
|
||||
return null;
|
||||
});
|
||||
}).exceptionally(throwable -> {
|
||||
returningFuture.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
return returningFuture;
|
||||
}
|
||||
|
||||
@@ -163,6 +163,9 @@ public class MuteServiceBean implements MuteService {
|
||||
channelService.sendTextToChannel(throwable.getMessage(), feedBackChannel).whenComplete((exceptionMessage, innerThrowable) -> {
|
||||
notificationFuture.complete(null);
|
||||
log.info("Successfully notified user {} in server {} about mute.", memberBeingMuted.getId(), memberBeingMuted.getGuild().getId());
|
||||
}).exceptionally(throwable1 -> {
|
||||
notificationFuture.completeExceptionally(throwable1);
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -155,14 +155,18 @@ public class PurgeServiceBean implements PurgeService {
|
||||
return aVoid -> {
|
||||
if (amountToDelete >= 1) {
|
||||
log.debug("Still more than 1 message to delete. Continuing.");
|
||||
purgeMessages(amountToDelete, channel, earliestMessage.getIdLong(), purgedMember, totalCount, currentCount, currentStatusMessageId).whenComplete((avoid, throwable) -> {
|
||||
purgeMessages(amountToDelete, channel, earliestMessage.getIdLong(), purgedMember, totalCount, currentCount, currentStatusMessageId)
|
||||
.whenComplete((avoid, throwable) -> {
|
||||
if (throwable != null) {
|
||||
deletionFuture.completeExceptionally(throwable);
|
||||
} else {
|
||||
deletionFuture.complete(null);
|
||||
}
|
||||
}
|
||||
);
|
||||
).exceptionally(throwable -> {
|
||||
deletionFuture.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
log.debug("Completed purging of {} messages.", totalCount);
|
||||
// Todo Move to message service
|
||||
|
||||
@@ -195,9 +195,13 @@ public class WarnServiceBean implements WarnService {
|
||||
log.warn("Could not find user {} in server {}. Not notifying about decayed warning {}.", userId, serverId, warningId);
|
||||
}
|
||||
});
|
||||
CompletableFuture<Void> future = new CompletableFuture();
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
FutureUtils.toSingleFutureGeneric(notificationFutures)
|
||||
.whenComplete((unused, throwable) -> future.complete(null));
|
||||
.whenComplete((unused, throwable) -> future.complete(null))
|
||||
.exceptionally(throwable -> {
|
||||
future.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user