From c4cbfe2a11f63cc7b8c8f576587b0f64d25e17cf Mon Sep 17 00:00:00 2001 From: Lachlan Pond Date: Mon, 27 Feb 2023 21:52:22 +1000 Subject: [PATCH 1/2] Catch JDA exception when there is no internet connection --- src/main/java/com/jagrosh/jmusicbot/JMusicBot.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index 5432bd30e..8f3f8489b 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -200,5 +200,11 @@ else if(config.getGame().getName().equalsIgnoreCase("none")) + "invalid: " + ex + "\nConfig Location: " + config.getConfigLocation()); System.exit(1); } + catch(ErrorResponseException ex) + { + prompt.alert(Prompt.Level.ERROR, "JMusicBot", ex + "\n Invalid reponse returned when " + + "attempting to connect, please make sure you're connected to the internet"); + System.exit(1); + } } } From 788cd40f2cde1450e2345def560e84984c1d2452 Mon Sep 17 00:00:00 2001 From: Lachlan Pond Date: Sat, 4 Mar 2023 13:59:42 +1000 Subject: [PATCH 2/2] Added import for ErrorResponseException --- src/main/java/com/jagrosh/jmusicbot/JMusicBot.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index 8f3f8489b..69248fc88 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -34,6 +34,7 @@ import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; +import net.dv8tion.jda.api.exceptions.ErrorResponseException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -202,7 +203,7 @@ else if(config.getGame().getName().equalsIgnoreCase("none")) } catch(ErrorResponseException ex) { - prompt.alert(Prompt.Level.ERROR, "JMusicBot", ex + "\n Invalid reponse returned when " + prompt.alert(Prompt.Level.ERROR, "JMusicBot", ex + "\nInvalid reponse returned when " + "attempting to connect, please make sure you're connected to the internet"); System.exit(1); }