You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(logger): friendlier handling of default values (#1263)
I have noticed that when inexperienced people just getting started on
the project go through all the hoops of cloning the repository, setting
up their Discord bots, creating their test server, they end up compiling
the code in IDEs like IntelliJ IDEA and assuming they just change the
token on their `config.json`, there are stacktraces and errors thrown
once they attempt to run the bot. Specifically:
Caused by: java.net.URISyntaxException: Illegal character in path at index 0: <put_your_webhook_here>
at java.base/java.net.URI$Parser.fail(URI.java:2995)
at java.base/java.net.URI$Parser.checkChars(URI.java:3166)
at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3248)
at java.base/java.net.URI$Parser.parse(URI.java:3207)
at java.base/java.net.URI.<init>(URI.java:645)
at java.base/java.net.URI.create(URI.java:930)
For the average software engineer, they would be aware that the program
is still running and that the bot is ready, but two things:
- Someone who is not trained enough and is just starting to contribute
will get thrown off by the error and potentially give up (I have
experienced it happening)
- It's a generally better experience for knowledgable new contributors
to set up the project effortlessly so that they can get started with
contributing straight away without any stacktraces.
This commit prints a friendly warning in the logger and no stacktrace in
case the user has not updated the webhooks (which most of them will not
have to, as they are primarily concerned with the Discord bot's token).
We hide the stacktrace in case there is a "<put_your_webhook_here>"
value in the "logInfoChannelWebhook" and "logErrorChannelWebhook"
configuration keys so that IntelliJ IDEA does not put the stacktrace in
the spotlight and potentially scare new contributors.
Signed-off-by: christolis <[email protected]>
if (webhookUri.equalsIgnoreCase(LOG_CHANNEL_WEBHOOK_DEFAULT_VALUE)) {
60
+
logger.warn(
61
+
"The {} webhook URL was not setup yet, logs will not be forwarded to Discord. Enter a valid webhook URL in your `config.json` if you want log forwarding.",
62
+
webhookName);
63
+
returnOptional.empty();
64
+
}
65
+
58
66
try {
59
67
returnOptional.of(URI.create(webhookUri));
60
68
} catch (IllegalArgumentExceptione) {
61
69
logger.warn(LogMarkers.NO_DISCORD,
62
-
"The webhook URL ({}) in the config is invalid, logs will not be forwarded to Discord.",
63
-
webhookUri, e);
70
+
"The {} webhook URL ({}) in the config is invalid, logs will not be forwarded to Discord.",
0 commit comments