mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 03:45:57 +00:00
added logging to several places concerning futures
This commit is contained in:
@@ -41,7 +41,7 @@ public class MessageEmbedListener implements MessageReceivedListener {
|
|||||||
Consumer<CachedMessage> cachedMessageConsumer = cachedMessage -> messageEmbedService.embedLink(cachedMessage, message.getTextChannel(), cause, message);
|
Consumer<CachedMessage> cachedMessageConsumer = cachedMessage -> messageEmbedService.embedLink(cachedMessage, message.getTextChannel(), cause, message);
|
||||||
messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId()).thenAccept(cachedMessageConsumer)
|
messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId()).thenAccept(cachedMessageConsumer)
|
||||||
.exceptionally(throwable -> {
|
.exceptionally(throwable -> {
|
||||||
log.error("Error when embedding link.", throwable);
|
log.error("Error when embedding link for message {}", message.getId(), throwable);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,10 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
|||||||
messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId())
|
messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId())
|
||||||
.thenAccept(cachedMessage ->
|
.thenAccept(cachedMessage ->
|
||||||
self.embedLink(cachedMessage, target, reason, embeddingMessage)
|
self.embedLink(cachedMessage, target, reason, embeddingMessage)
|
||||||
)
|
).exceptionally(throwable -> {
|
||||||
|
log.error("Message retrieval from cache failed for message {}.", messageEmbedLink.getMessageId(), throwable);
|
||||||
|
return null;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +124,10 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
|||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
log.error("Failed to post message embed.", e);
|
log.error("Failed to post message embed.", e);
|
||||||
}
|
}
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to send message for embedding the link for message {} in channel {} in server {}",
|
||||||
|
cachedMessage.getMessageId(), cachedMessage.getChannelId(), cachedMessage.getServerId(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ public class StarboardServiceBean implements StarboardService {
|
|||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
log.error("Failed to post messages.", e);
|
log.error("Failed to post messages.", e);
|
||||||
}
|
}
|
||||||
|
}) .exceptionally(throwable -> {
|
||||||
|
log.error("Failed to create starboard post for message {} in channel {} in server {}", message.getMessageId(), message.getChannelId(), message.getServerId(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -125,6 +128,9 @@ public class StarboardServiceBean implements StarboardService {
|
|||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
log.error("Failed to post starboard post.", e);
|
log.error("Failed to post starboard post.", e);
|
||||||
}
|
}
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to update starboard post {}.", post.getId(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ public class SuggestionServiceBean implements SuggestionService {
|
|||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
log.warn("Failed to post suggestion", e);
|
log.warn("Failed to post suggestion", e);
|
||||||
}
|
}
|
||||||
|
}) .exceptionally(throwable -> {
|
||||||
|
log.error("Failed to post suggestion {}", suggestion.getId(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.warn("Guild {} or member {} was not found when creating suggestion.", member.getGuild().getIdLong(), member.getIdLong());
|
log.warn("Guild {} or member {} was not found when creating suggestion.", member.getGuild().getIdLong(), member.getIdLong());
|
||||||
|
|||||||
@@ -35,7 +35,12 @@ public class MessageDeletedListenerBean extends ListenerAdapter {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void onGuildMessageDelete(@Nonnull GuildMessageDeleteEvent event) {
|
public void onGuildMessageDelete(@Nonnull GuildMessageDeleteEvent event) {
|
||||||
Consumer<CachedMessage> cachedMessageConsumer = cachedMessage -> self.executeListener(cachedMessage);
|
Consumer<CachedMessage> cachedMessageConsumer = cachedMessage -> self.executeListener(cachedMessage);
|
||||||
messageCache.getMessageFromCache(event.getGuild().getIdLong(), event.getChannel().getIdLong(), event.getMessageIdLong()).thenAccept(cachedMessageConsumer);
|
messageCache.getMessageFromCache(event.getGuild().getIdLong(), event.getChannel().getIdLong(), event.getMessageIdLong())
|
||||||
|
.thenAccept(cachedMessageConsumer)
|
||||||
|
.exceptionally(throwable -> {
|
||||||
|
log.error("Message retrieval {} from cache failed. ", event.getMessageIdLong(), throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ public class MessageUpdatedListener extends ListenerAdapter {
|
|||||||
messageCache.getMessageFromCache(message.getGuild().getIdLong(), message.getTextChannel().getIdLong(), event.getMessageIdLong()).thenAccept(cachedMessage -> {
|
messageCache.getMessageFromCache(message.getGuild().getIdLong(), message.getTextChannel().getIdLong(), event.getMessageIdLong()).thenAccept(cachedMessage -> {
|
||||||
self.executeListener(message, cachedMessage);
|
self.executeListener(message, cachedMessage);
|
||||||
messageCache.putMessageInCache(message);
|
messageCache.putMessageInCache(message);
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Message retrieval {} from cache failed. ", event.getMessage().getId(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,13 @@ public class ReactionUpdatedListener extends ListenerAdapter {
|
|||||||
future.thenAccept(reaction -> {
|
future.thenAccept(reaction -> {
|
||||||
self.callAddedListeners(event, cachedMessage, reaction);
|
self.callAddedListeners(event, cachedMessage, reaction);
|
||||||
messageCache.putMessageInCache(cachedMessage);
|
messageCache.putMessageInCache(cachedMessage);
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to add reaction to message {} ", event.getMessageIdLong(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Message retrieval {} from cache failed. ", event.getMessageIdLong(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,9 +128,15 @@ public class ReactionUpdatedListener extends ListenerAdapter {
|
|||||||
messageCache.getCachedReactionFromReaction(future, event.getReaction());
|
messageCache.getCachedReactionFromReaction(future, event.getReaction());
|
||||||
future.thenAccept(reaction ->
|
future.thenAccept(reaction ->
|
||||||
self.callRemoveListeners(event, cachedMessage, reaction)
|
self.callRemoveListeners(event, cachedMessage, reaction)
|
||||||
);
|
) .exceptionally(throwable -> {
|
||||||
|
log.error("Failed to retrieve cached reaction for message {} ", event.getMessageIdLong(), throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
messageCache.putMessageInCache(cachedMessage);
|
messageCache.putMessageInCache(cachedMessage);
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Message retrieval {} from cache failed. ", event.getMessageIdLong(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +164,9 @@ public class ReactionUpdatedListener extends ListenerAdapter {
|
|||||||
asyncMessageFromCache.thenAccept(cachedMessage -> {
|
asyncMessageFromCache.thenAccept(cachedMessage -> {
|
||||||
cachedMessage.getReactions().clear();
|
cachedMessage.getReactions().clear();
|
||||||
messageCache.putMessageInCache(cachedMessage);
|
messageCache.putMessageInCache(cachedMessage);
|
||||||
|
}) .exceptionally(throwable -> {
|
||||||
|
log.error("Message retrieval from cache failed for message {}", event.getMessageIdLong(), throwable);
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,10 @@ public class MessageCacheBean implements MessageCache {
|
|||||||
.timeCreated(Instant.from(message.getTimeCreated()))
|
.timeCreated(Instant.from(message.getTimeCreated()))
|
||||||
.attachmentUrls(attachmentUrls)
|
.attachmentUrls(attachmentUrls)
|
||||||
.build())
|
.build())
|
||||||
);
|
).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to load reactions for message {}. ", message.getId(), throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CachedReaction> getFutures(List<CompletableFuture<CachedReaction>> futures) {
|
private List<CachedReaction> getFutures(List<CompletableFuture<CachedReaction>> futures) {
|
||||||
@@ -153,7 +156,11 @@ public class MessageCacheBean implements MessageCache {
|
|||||||
users.forEachAsync(user -> {
|
users.forEachAsync(user -> {
|
||||||
ausers.add(AUser.builder().id(user.getIdLong()).build());
|
ausers.add(AUser.builder().id(user.getIdLong()).build());
|
||||||
return false;
|
return false;
|
||||||
}).thenAccept(o -> future.complete(builder.build()));
|
}).thenAccept(o -> future.complete(builder.build()))
|
||||||
|
.exceptionally(throwable -> {
|
||||||
|
log.error("Failed to load reaction users.", throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
builder.users(ausers);
|
builder.users(ausers);
|
||||||
builder.emote(emoteService.buildAEmoteFromReaction(reaction.getReactionEmote()));
|
builder.emote(emoteService.buildAEmoteFromReaction(reaction.getReactionEmote()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,10 +118,16 @@ public class PostTargetServiceBean implements PostTargetService {
|
|||||||
.queue(
|
.queue(
|
||||||
existingMessage -> existingMessage
|
existingMessage -> existingMessage
|
||||||
.editMessage(messageToSend.getEmbeds().get(0))
|
.editMessage(messageToSend.getEmbeds().get(0))
|
||||||
.submit().thenAccept(message -> future.get(0).complete(message)),
|
.submit().thenAccept(message -> future.get(0).complete(message)).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to edit message {}.", messageId, throwable);
|
||||||
|
return null;
|
||||||
|
}),
|
||||||
throwable ->
|
throwable ->
|
||||||
sendEmbedInPostTarget(messageToSend, target).get(0)
|
sendEmbedInPostTarget(messageToSend, target).get(0)
|
||||||
.thenAccept(message -> future.get(0).complete(message))
|
.thenAccept(message -> future.get(0).complete(message)) .exceptionally(innerThrowable -> {
|
||||||
|
log.error("Failed to send message to create a message.", innerThrowable);
|
||||||
|
return null;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
textChannelForPostTarget
|
textChannelForPostTarget
|
||||||
@@ -130,10 +136,16 @@ public class PostTargetServiceBean implements PostTargetService {
|
|||||||
existingMessage -> existingMessage
|
existingMessage -> existingMessage
|
||||||
.editMessage(messageToSend.getMessage())
|
.editMessage(messageToSend.getMessage())
|
||||||
.embed(messageToSend.getEmbeds().get(0))
|
.embed(messageToSend.getEmbeds().get(0))
|
||||||
.submit().thenAccept(message -> future.get(0).complete(message)),
|
.submit().thenAccept(message -> future.get(0).complete(message)).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to edit message {}", messageId, throwable);
|
||||||
|
return null;
|
||||||
|
}),
|
||||||
throwable ->
|
throwable ->
|
||||||
sendEmbedInPostTarget(messageToSend, target).get(0)
|
sendEmbedInPostTarget(messageToSend, target).get(0)
|
||||||
.thenAccept(message -> future.get(0).complete(message))
|
.thenAccept(message -> future.get(0).complete(message)).exceptionally(innerThrowable -> {
|
||||||
|
log.error("Failed to send message to create a message.", innerThrowable);
|
||||||
|
return null;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user