From 7b7218ad4ed486326808b9da9b79ae0ad7811e8f Mon Sep 17 00:00:00 2001 From: OMGeeky <> Date: Wed, 30 Aug 2023 14:48:56 +0200 Subject: [PATCH] Add error handling for update check timeouts and HTTP status exceptions --- src/com/gpl/rpg/atcontentstudio/ATContentStudio.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java index 3d96057..8bb3fc3 100644 --- a/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java +++ b/src/com/gpl/rpg/atcontentstudio/ATContentStudio.java @@ -20,6 +20,10 @@ import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; +import java.net.http.HttpTimeoutException; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.*; import java.util.logging.Level; @@ -183,8 +187,14 @@ public class ATContentStudio { } } catch (MalformedURLException e) { e.printStackTrace(); + } catch (HttpTimeoutException e) { + System.out.println("Could not connect to url to check for updates (timeout): " + CHECK_UPDATE_URL); } catch (IOException e) { - e.printStackTrace(); + if (e.getMessage() != null && e.getMessage().startsWith("Server returned HTTP response code:")) { + System.out.println("Could not fetch current version from server to check for updates (non-success-status): " + e.getMessage()); + } else { + System.out.println("Could not check for updates: '" + CHECK_UPDATE_URL + "' - " + e.getMessage()); + } } finally { try { if (in != null)