Generate hard failures when critical components can not be initialized
Created by: NiklasRosenstein
In many places, exceptions are being logged but otherwise stay unhandled. Often times this merely shadows the actual problem and makes it hard to track the cause of an issue.
Example:
I suggest that these throw an appropriate exception. IMHO a RuntimeException would be fine in scenarios like these, as the most likely result is that preconditions are not met (eg. the discord token is not configured) and the error prevents the whole application from functioning properly, anyway.
try {
client = new ClientBuilder().withToken(Token).login();
} catch (DiscordException ex) {
Logger.getGlobal().log(Level.SEVERE, "Discord client could not be created.", ex);
throw new RuntimeException("Discord client could not be created.");
}
With the original code, you receive a NullPointerException later in the method instead of an exception that the Discord client could not be created.