Skip to content

Commit

Permalink
Better errors when update check fails
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueTree242 committed Mar 25, 2024
1 parent 63c0281 commit 44e5d76
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void performStartUpdateCheck() {
getLogger().severe(msg);
break;
}
} catch (Exception ex) {
} catch (Throwable ex) {
getLogger().severe(String.format("Could not check for updates: %s", ex.getMessage()));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onPlayerJoin(PostLoginEvent e) {
if (msg != null) {
e.getPlayer().sendMessage(msg);
}
} catch (Exception ex) {
} catch (Throwable ex) {
core.getLogger().severe(String.format("Could not check for updates: %s", ex.getMessage()));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.List;

public class CompleterModifier {
private static final List BAD_COMMANDS = Arrays.asList("ver", "version", "plugins", "bukkit:plugins", "bukkit:ver", "bukkit:version", "about", "bukkit:about", "?", "minecraft:?");
private static final List<String> BAD_COMMANDS = Arrays.asList("ver", "version", "plugins", "bukkit:plugins", "bukkit:ver", "bukkit:version", "about", "bukkit:about", "?", "minecraft:?");

public static void removePluginPrefix(CommandCompleterList list) {
for (CommandCompleter completer : new ArrayList<>(list)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Group mergeGroups(List<Group> groups) {
return new Group(name, tabcomplete);
}

public UpdateCheckResult updateCheck() {
public UpdateCheckResult updateCheck() throws Throwable {
try {
HttpClient client = HttpClient.newBuilder()
.withBaseURL("https://advancedplhide.bluetree242.dev")
Expand All @@ -116,8 +116,8 @@ public UpdateCheckResult updateCheck() {
.execute();
JSONObject json = new JSONObject(new String(Objects.requireNonNull(response).getRawResponse(), StandardCharsets.UTF_8));
return new UpdateCheckResult(json.getInt("versions_behind"), json.isNull("message") ? null : json.getString("message"), json.isNull("type") ? "INFO" : json.getString("type"), json.getString("downloadUrl"));
} catch (Exception e) {
throw new RuntimeException(e);
} catch (RuntimeException e) {
throw e.getCause();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void performStartUpdateCheck() {
getLogger().severe(msg);
break;
}
} catch (Exception ex) {
} catch (Throwable ex) {
getLogger().severe(String.format("Could not check for updates: %s", ex.getMessage()));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void onPlayerJoin(PlayerJoinEvent e) {
if (msg != null) {
e.getPlayer().sendMessage(msg);
}
} catch (Exception ex) {
} catch (Throwable ex) {
core.getLogger().severe(String.format("Could not check for updates: %s", ex.getMessage()));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void performStartUpdateCheck() {
logger.error(msg);
break;
}
} catch (Exception ex) {
} catch (Throwable ex) {
logger.error(String.format("Could not check for updates: %s", ex.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void onPlayerJoin(PostLoginEvent e) {
msg = msg.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, result.getUpdateUrl()));
e.getPlayer().sendMessage(msg);
}
} catch (Exception ex) {
} catch (Throwable ex) {
core.getLogger().error(String.format("Could not check for updates: %s", ex.getMessage()));
}
}).schedule();
Expand Down

0 comments on commit 44e5d76

Please sign in to comment.