Skip to content

Commit

Permalink
refactor: adjust debug messaging slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Dec 8, 2024
1 parent 6a6d376 commit 5cf7d01
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,21 @@ private CompletableFuture<String> formatPlaceholders(@NotNull String text, @NotN
.build())
.put(text, formatted);
return formatted;
}).exceptionally(throwable -> {
}).exceptionally(e -> {
if (!requester.isConnected()) {
return text;
}
if (throwable instanceof CompletionException || Arrays.stream(throwable.getSuppressed()).anyMatch(TimeoutException.class::isInstance)) {
plugin.log(Level.SEVERE, "Timed out formatting placeholders for " + requester.getUsername() +
" timeout: " + requestTimeout + "ms. Is PapiProxyBridge up-to-date and installed on all backend servers?");

// Handle failed to format exceptions
if (e instanceof CompletionException || Arrays.stream(e.getSuppressed())
.anyMatch(TimeoutException.class::isInstance)) {
plugin.log(Level.WARNING, ("Timed out formatting placeholders for %s after %sms." +
"Is PAPIProxyBridge up-to-date and installed on all backend servers?")
.formatted(requester.getUsername(), getRequestTimeout()));
} else {
plugin.log(Level.WARNING, "Failed to format placeholders for " + requester.getUsername(), throwable);
plugin.log(Level.WARNING, "Failed to format placeholders for %s".formatted(requester.getUsername()), e);
}

return text;
});
}
Expand Down Expand Up @@ -253,16 +258,21 @@ private CompletableFuture<Component> formatComponentPlaceholders(@NotNull String
.build())
.put(text, deserialized);
return deserialized;
}).exceptionally(throwable -> {
}).exceptionally(e -> {
if (!requester.isConnected()) {
return Component.text(text);
}
if (throwable instanceof CompletionException || Arrays.stream(throwable.getSuppressed()).anyMatch(TimeoutException.class::isInstance)) {
plugin.log(Level.SEVERE, "Timed out formatting placeholders for " + requester.getUsername() +
" timeout: " + requestTimeout + "ms. Is PapiProxyBridge up-to-date and installed on all backend servers?");

// Handle failed to format exceptions
if (e instanceof CompletionException || Arrays.stream(e.getSuppressed())
.anyMatch(TimeoutException.class::isInstance)) {
plugin.log(Level.WARNING, ("Timed out formatting placeholders for %s after %sms." +
"Is PAPIProxyBridge up-to-date and installed on all backend servers?")
.formatted(requester.getUsername(), getRequestTimeout()));
} else {
plugin.log(Level.WARNING, "Failed to format placeholders for " + requester.getUsername(), throwable);
plugin.log(Level.WARNING, "Failed to format placeholders for %s".formatted(requester.getUsername()), e);
}

return Component.text(text);
});
}
Expand Down

0 comments on commit 5cf7d01

Please sign in to comment.