Skip to content

Commit e47a0ac

Browse files
authored
fix(GithubReference): log a warn if init goes wrong (#1030)
* Catches the exception and logs when github key used in config is invalid. Otherwise, bot crashes, even when the feature is disabled.
1 parent 2c46e3e commit e47a0ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubReference.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
1010
import org.apache.commons.collections4.ListUtils;
1111
import org.kohsuke.github.*;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
1214

1315
import org.togetherjava.tjbot.config.Config;
1416
import org.togetherjava.tjbot.features.MessageReceiverAdapter;
@@ -34,6 +36,7 @@
3436
*/
3537
public final class GitHubReference extends MessageReceiverAdapter {
3638
static final String ID_GROUP = "id";
39+
private static final Logger logger = LoggerFactory.getLogger(GitHubReference.class);
3740

3841
/**
3942
* The pattern(#123) used to determine whether a message is referencing an issue.
@@ -86,7 +89,9 @@ private void acquireRepositories() {
8689
repositories.add(githubApi.getRepositoryById(repoId));
8790
}
8891
} catch (IOException ex) {
89-
throw new UncheckedIOException(ex);
92+
logger.warn(
93+
"The GitHub key ({}) used in this config is invalid. Skipping GitHubReference feature – {}",
94+
config.getGitHubApiKey(), ex.getMessage());
9095
}
9196
}
9297

0 commit comments

Comments
 (0)