From 101425a562b3d95b55a067f867a78dac2be2a7de Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Fri, 12 Jun 2015 14:52:31 -0500 Subject: [PATCH] Catch UnknownHostException and write a friendlier warning. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/db/BeatmapDB.java | 2 +- src/itdelatrisu/opsu/downloads/Updater.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/itdelatrisu/opsu/db/BeatmapDB.java b/src/itdelatrisu/opsu/db/BeatmapDB.java index 6f0fcca0..3f85373e 100644 --- a/src/itdelatrisu/opsu/db/BeatmapDB.java +++ b/src/itdelatrisu/opsu/db/BeatmapDB.java @@ -479,7 +479,7 @@ public class BeatmapDB { beatmap.epilepsyWarning = rs.getBoolean(35); String bg = rs.getString(36); if (bg != null) - beatmap.bg = new File(dir, BeatmapParser.getDBString(rs.getString(36))); + beatmap.bg = new File(dir, BeatmapParser.getDBString(bg)); beatmap.sliderBorderFromString(rs.getString(37)); } catch (SQLException e) { throw e; diff --git a/src/itdelatrisu/opsu/downloads/Updater.java b/src/itdelatrisu/opsu/downloads/Updater.java index a7b5ca61..366fb623 100644 --- a/src/itdelatrisu/opsu/downloads/Updater.java +++ b/src/itdelatrisu/opsu/downloads/Updater.java @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; import java.net.URL; +import java.net.UnknownHostException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -35,6 +36,7 @@ import java.util.Locale; import java.util.Properties; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.newdawn.slick.util.Log; import org.newdawn.slick.util.ResourceLoader; /** @@ -206,7 +208,12 @@ public class Updater { return; // get latest version - String s = Utils.readDataFromUrl(new URL(Options.VERSION_REMOTE)); + String s = null; + try { + s = Utils.readDataFromUrl(new URL(Options.VERSION_REMOTE)); + } catch (UnknownHostException e) { + Log.warn(String.format("Check for updates failed. Please check your internet connection, or your connection to %s.", Options.VERSION_REMOTE)); + } if (s == null) { status = Status.CONNECTION_ERROR; return;