mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-24 05:39:44 +00:00
[AB-323] improving logging when using whenComplete
This commit is contained in:
@@ -36,21 +36,18 @@ public class AUserInAServerParameterHandlerImpl implements AUserInAServerParamet
|
||||
Parameter cloned = commandService.cloneParameter(param);
|
||||
cloned.setType(Member.class);
|
||||
memberParameterHandler.handleAsync(input, iterators, cloned, context, command).whenComplete((o, throwable) -> {
|
||||
try {
|
||||
AUserInAServer actualInstance;
|
||||
if (throwable == null) {
|
||||
Member member = (Member) o;
|
||||
actualInstance = userInServerManagementService.loadOrCreateUser(member);
|
||||
} else {
|
||||
Long userId = Long.parseLong(((String) input.getValue()).trim());
|
||||
actualInstance = userInServerManagementService.loadAUserInAServerOptional(context.getGuild().getIdLong(), userId).orElseThrow(() -> new UserInServerNotFoundException(0L));
|
||||
}
|
||||
future.complete(AUserInAServer.builder().userInServerId(actualInstance.getUserInServerId()).build());
|
||||
} catch (Exception e) {
|
||||
// we need to do it like this, because when complete only returns the exception it got in case two exceptions happen
|
||||
// so if the first exception happens in handleAsync, and we also throw one, it will _not_ get reported, because the other exception overshadows it
|
||||
future.completeExceptionally(e);
|
||||
AUserInAServer actualInstance;
|
||||
if (throwable == null) {
|
||||
Member member = (Member) o;
|
||||
actualInstance = userInServerManagementService.loadOrCreateUser(member);
|
||||
} else {
|
||||
Long userId = Long.parseLong(((String) input.getValue()).trim());
|
||||
actualInstance = userInServerManagementService.loadAUserInAServerOptional(context.getGuild().getIdLong(), userId).orElseThrow(() -> new UserInServerNotFoundException(0L));
|
||||
}
|
||||
future.complete(AUserInAServer.builder().userInServerId(actualInstance.getUserInServerId()).build());
|
||||
}).exceptionally(throwable -> {
|
||||
future.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,9 @@ public class CombinedParameterHandlerImpl implements CombinedParametersHandler {
|
||||
}
|
||||
}
|
||||
returningFuture.completeExceptionally(new IncorrectParameterException(command, param.getName()));
|
||||
}).exceptionally(throwable -> {
|
||||
returningFuture.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
return returningFuture;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,13 @@ public class UndoActionPostExecution implements PostCommandExecution {
|
||||
log.info("Performing undo cations for command {} in server {}.", command.getConfiguration().getName(), commandContext.getGuild().getIdLong());
|
||||
undoActionService.performActionsFuture(commandContext.getUndoActions()).whenComplete((aVoid, undoThrowable) -> {
|
||||
if(undoThrowable != null) {
|
||||
log.warn("Undo actions failed.", undoThrowable);
|
||||
log.error("Undo actions failed.", undoThrowable);
|
||||
} else {
|
||||
log.info("Successfully executed undo actions.");
|
||||
}
|
||||
}).exceptionally(throwable -> {
|
||||
log.error("Undo complete failed.", throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,9 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
builder.self(reaction.isSelf());
|
||||
builder.emote(getCachedEmoteFromEmote(reaction.getReactionEmote(), reaction.getGuild()));
|
||||
future.complete(builder.build());
|
||||
}).exceptionally(throwable -> {
|
||||
future.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user