refactor errorhandler

This commit is contained in:
yugecin
2017-05-27 01:46:50 +02:00
parent a5efe7e649
commit 08f5bfc27f
23 changed files with 191 additions and 209 deletions

View File

@@ -869,7 +869,8 @@ public enum GameImage {
skinImages = null;
}
} catch (SlickException e) {
ErrorHandler.error(String.format("Failed to destroy beatmap skin images for '%s'.", this.name()), e).show();
String msg = String.format("Failed to destroy beatmap skin images for '%s'.", this.name());
ErrorHandler.explode(msg, e, ErrorHandler.DEFAULT_OPTIONS);
}
}

View File

@@ -46,9 +46,8 @@ import org.newdawn.slick.util.Log;
import com.sun.jna.platform.FileUtils;
import yugecin.opsudance.core.NotNull;
import yugecin.opsudance.core.Nullable;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BubNotifListener;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
@@ -313,7 +312,7 @@ public class Utils {
try {
json = new JSONObject(s);
} catch (JSONException e) {
ErrorHandler.error("Failed to create JSON object.", e).show();
explode("Failed to create JSON object.", e, DEFAULT_OPTIONS);
}
}
return json;
@@ -332,7 +331,7 @@ public class Utils {
try {
json = new JSONArray(s);
} catch (JSONException e) {
ErrorHandler.error("Failed to create JSON array.", e).show();
explode("Failed to create JSON array.", e, DEFAULT_OPTIONS);
}
}
return json;
@@ -374,7 +373,7 @@ public class Utils {
result.append(String.format("%02x", b));
return result.toString();
} catch (NoSuchAlgorithmException | IOException e) {
ErrorHandler.error("Failed to calculate MD5 hash.", e).show();
explode("Failed to calculate MD5 hash.", e, DEFAULT_OPTIONS);
}
return null;
}

View File

@@ -1,7 +1,5 @@
package itdelatrisu.opsu.audio;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
@@ -14,6 +12,8 @@ import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Extension of Clip that allows playing multiple copies of a Clip simultaneously.
* http://stackoverflow.com/questions/1854616/
@@ -194,7 +194,8 @@ public class MultiClip {
try {
audioIn.close();
} catch (IOException e) {
ErrorHandler.error(String.format("Could not close AudioInputStream for MultiClip %s.", name), e).show();
explode(String.format("Could not close AudioInputStream for MultiClip %s.", name), e,
DEFAULT_OPTIONS);
}
}
}

View File

@@ -45,10 +45,10 @@ import org.newdawn.slick.openal.SoundStore;
import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader;
import org.tritonus.share.sampled.file.TAudioFileFormat;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.options.Options.*;
/**
@@ -576,7 +576,7 @@ public class MusicController {
player = null;
} catch (Exception e) {
ErrorHandler.error("Failed to destroy OpenAL.", e).show();
explode("Failed to destroy OpenAL.", e, DEFAULT_OPTIONS);
}
}

View File

@@ -39,12 +39,12 @@ import javax.sound.sampled.LineUnavailableException;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.skinning.SkinService;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.options.Options.*;
/**
@@ -104,7 +104,7 @@ public class SoundController {
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
return loadClip(ref, audioIn, isMP3);
} catch (Exception e) {
ErrorHandler.error(String.format("Failed to load file '%s'.", ref), e).show();
explode(String.format("Failed to load file '%s'.", ref), e, DEFAULT_OPTIONS);
return null;
}
}
@@ -285,7 +285,7 @@ public class SoundController {
try {
clip.start(volume, listener);
} catch (LineUnavailableException e) {
ErrorHandler.error(String.format("Could not start a clip '%s'.", clip.getName()), e).show();
explode(String.format("Could not start a clip '%s'.", clip.getName()), e, DEFAULT_OPTIONS);
}
}
}

View File

@@ -35,10 +35,10 @@ import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.Color;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.Nullable;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BubNotifListener;
import yugecin.opsudance.skinning.SkinService;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
@@ -250,7 +250,7 @@ public class BeatmapParser {
} catch (IOException e) {
logAndShowErrorNotification(e, "Failed to read file '%s'.", map.getFile().getAbsolutePath());
} catch (NoSuchAlgorithmException e) {
ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
explode("Failed to get MD5 hash stream.", e, DEFAULT_OPTIONS);
// retry without MD5
hasNoMD5Algorithm = true;
@@ -653,7 +653,7 @@ public class BeatmapParser {
} catch (IOException e) {
logAndShowErrorNotification(e, "Failed to read file '%s'.", file.getAbsolutePath());
} catch (NoSuchAlgorithmException e) {
ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
explode("Failed to get MD5 hash stream.", e, DEFAULT_OPTIONS);
// retry without MD5
hasNoMD5Algorithm = true;
@@ -811,8 +811,9 @@ public class BeatmapParser {
// check that all objects were parsed
if (objectIndex != beatmap.objects.length)
ErrorHandler.error(String.format("Parsed %d objects for beatmap '%s', %d objects expected.",
objectIndex, beatmap.toString(), beatmap.objects.length), new Exception("no")).show();
explode(String.format("Parsed %d objects for beatmap '%s', %d objects expected.",
objectIndex, beatmap.toString(), beatmap.objects.length), new Exception("no"),
DEFAULT_OPTIONS);
} catch (IOException e) {
logAndShowErrorNotification(e, "Failed to read file '%s'.",
beatmap.getFile().getAbsolutePath());

View File

@@ -33,8 +33,9 @@ import java.util.List;
import java.util.Map;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.options.Configuration;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
* Handles connections and queries with the cached beatmap database.
@@ -89,17 +90,10 @@ public class BeatmapDB {
/** Current size of beatmap cache table. */
private static int cacheSize = -1;
// This class should not be instantiated.
private BeatmapDB() {}
private static Configuration config; // TODO
/**
* Initializes the database connection.
*/
public static void init(Configuration config) {
BeatmapDB.config = config;
public static void init() {
// create a database connection
connection = DBController.createConnection(config.BEATMAP_DB.getPath());
if (connection == null)
@@ -115,7 +109,7 @@ public class BeatmapDB {
try {
updateSizeStmt = connection.prepareStatement("REPLACE INTO info (key, value) VALUES ('size', ?)");
} catch (SQLException e) {
ErrorHandler.error("Failed to prepare beatmap statements.", e).show();
explode("Failed to prepare beatmap statements.", e, DEFAULT_OPTIONS);
}
// retrieve the cache size
@@ -137,7 +131,7 @@ public class BeatmapDB {
updatePlayStatsStmt = connection.prepareStatement("UPDATE beatmaps SET playCount = ?, lastPlayed = ? WHERE dir = ? AND file = ?");
setFavoriteStmt = connection.prepareStatement("UPDATE beatmaps SET favorite = ? WHERE dir = ? AND file = ?");
} catch (SQLException e) {
ErrorHandler.error("Failed to prepare beatmap statements.", e).show();
explode("Failed to prepare beatmap statements.", e, DEFAULT_OPTIONS);
}
}
@@ -175,7 +169,7 @@ public class BeatmapDB {
sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', '%s')", DATABASE_VERSION);
stmt.executeUpdate(sql);
} catch (SQLException e) {
ErrorHandler.error("Coudl not create beatmap database.", e).show();
explode("Could not create beatmap database.", e, DEFAULT_OPTIONS);
}
}
@@ -227,7 +221,7 @@ public class BeatmapDB {
ps.close();
}
} catch (SQLException e) {
ErrorHandler.error("Failed to update beatmap database.", e).show();
explode("Failed to update beatmap database.", e, DEFAULT_OPTIONS);
}
}
@@ -245,7 +239,7 @@ public class BeatmapDB {
}
rs.close();
} catch (SQLException e) {
ErrorHandler.error("Could not get beatmap cache size.", e).show();
explode("Could not get beatmap cache size.", e, DEFAULT_OPTIONS);
}
}
@@ -260,7 +254,7 @@ public class BeatmapDB {
updateSizeStmt.setString(1, Integer.toString(Math.max(cacheSize, 0)));
updateSizeStmt.executeUpdate();
} catch (SQLException e) {
ErrorHandler.error("Could not update beatmap cache size.", e).show();
explode("Could not update beatmap cache size.", e, DEFAULT_OPTIONS);
}
}
@@ -278,7 +272,7 @@ public class BeatmapDB {
cacheSize = 0;
updateCacheSize();
} catch (SQLException e) {
ErrorHandler.error("Could not drop beatmap database.", e).show();
explode("Could not drop beatmap database.", e, DEFAULT_OPTIONS);
}
createDatabase();
}
@@ -296,7 +290,7 @@ public class BeatmapDB {
cacheSize += insertStmt.executeUpdate();
updateCacheSize();
} catch (SQLException e) {
ErrorHandler.error("Failed to add beatmap to database.", e).show();
explode("Failed to add beatmap to database.", e, DEFAULT_OPTIONS);
}
}
@@ -349,7 +343,7 @@ public class BeatmapDB {
// update cache size
updateCacheSize();
} catch (SQLException e) {
ErrorHandler.error("Failed to add beatmaps to database.", e).show();
explode("Failed to add beatmaps to database.", e, DEFAULT_OPTIONS);
}
}
@@ -437,7 +431,7 @@ public class BeatmapDB {
}
rs.close();
} catch (SQLException e) {
ErrorHandler.error("Failed to load Beatmap from database.", e).show();
explode("Failed to load Beatmap from database.", e, DEFAULT_OPTIONS);
}
}
@@ -500,7 +494,7 @@ public class BeatmapDB {
}
rs.close();
} catch (SQLException e) {
ErrorHandler.error("Failed to load beatmaps from database.", e).show();
explode("Failed to load beatmaps from database.", e, DEFAULT_OPTIONS);
}
}
@@ -601,7 +595,7 @@ public class BeatmapDB {
rs.close();
return map;
} catch (SQLException e) {
ErrorHandler.error("Failed to get last modified map from database.", e).show();
explode("Failed to get last modified map from database.", e, DEFAULT_OPTIONS);
return null;
}
}
@@ -621,7 +615,7 @@ public class BeatmapDB {
cacheSize -= deleteMapStmt.executeUpdate();
updateCacheSize();
} catch (SQLException e) {
ErrorHandler.error("Failed to delete beatmap entry from database.", e).show();
explode("Failed to delete beatmap entry from database.", e, DEFAULT_OPTIONS);
}
}
@@ -638,7 +632,7 @@ public class BeatmapDB {
cacheSize -= deleteGroupStmt.executeUpdate();
updateCacheSize();
} catch (SQLException e) {
ErrorHandler.error("Failed to delete beatmap group entry from database.", e).show();
explode("Failed to delete beatmap group entry from database.", e, DEFAULT_OPTIONS);
}
}
@@ -656,8 +650,8 @@ public class BeatmapDB {
setStarsStmt.setString(3, beatmap.getFile().getName());
setStarsStmt.executeUpdate();
} catch (SQLException e) {
ErrorHandler.error(String.format("Failed to save star rating '%.4f' for beatmap '%s' in database.",
beatmap.starRating, beatmap.toString()), e).show();
explode(String.format("Failed to save star rating '%.4f' for beatmap '%s' in database.",
beatmap.starRating, beatmap.toString()), e, DEFAULT_OPTIONS);
}
}
@@ -676,8 +670,8 @@ public class BeatmapDB {
updatePlayStatsStmt.setString(4, beatmap.getFile().getName());
updatePlayStatsStmt.executeUpdate();
} catch (SQLException e) {
ErrorHandler.error(String.format("Failed to update play statistics for beatmap '%s' in database.",
beatmap.toString()), e).show();
explode(String.format("Failed to update play statistics for beatmap '%s' in database.",
beatmap.toString()), e, DEFAULT_OPTIONS);
}
}
@@ -695,8 +689,8 @@ public class BeatmapDB {
setFavoriteStmt.setString(3, beatmap.getFile().getName());
setFavoriteStmt.executeUpdate();
} catch (SQLException e) {
ErrorHandler.error(String.format("Failed to update favorite status for beatmap '%s' in database.",
beatmap.toString()), e).show();
explode(String.format("Failed to update favorite status for beatmap '%s' in database.",
beatmap.toString()), e, DEFAULT_OPTIONS);
}
}
@@ -716,7 +710,7 @@ public class BeatmapDB {
connection.close();
connection = null;
} catch (SQLException e) {
ErrorHandler.error("Failed to close beatmap database.", e).show();
explode("Failed to close beatmap database.", e, DEFAULT_OPTIONS);
}
}
}

View File

@@ -18,13 +18,12 @@
package itdelatrisu.opsu.db;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.options.Configuration;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Database controller.
*/
@@ -35,17 +34,17 @@ public class DBController {
/**
* Initializes all databases.
*/
public static void init(Configuration config) {
public static void init() {
// load the sqlite-JDBC driver using the current class loader
try {
Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
ErrorHandler.error("Could not load sqlite-JDBC driver.", e).show();
explode("Could not load sqlite-JDBC driver.", e, DEFAULT_OPTIONS);
}
// initialize the databases
BeatmapDB.init(config);
ScoreDB.init(config);
BeatmapDB.init();
ScoreDB.init();
}
/**
@@ -66,7 +65,7 @@ public class DBController {
return DriverManager.getConnection(String.format("jdbc:sqlite:%s", path));
} catch (SQLException e) {
// if the error message is "out of memory", it probably means no database file is found
ErrorHandler.error(String.format("Could not connect to database: '%s'.", path), e).show();
explode(String.format("Could not connect to database: '%s'.", path), e, DEFAULT_OPTIONS);
return null;
}
}

View File

@@ -20,8 +20,6 @@ package itdelatrisu.opsu.db;
import itdelatrisu.opsu.ScoreData;
import itdelatrisu.opsu.beatmap.Beatmap;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.options.Configuration;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -36,6 +34,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
* Handles connections and queries with the scores database.
*/
@@ -77,13 +78,10 @@ public class ScoreDB {
/** Score deletion statement. */
private static PreparedStatement deleteSongStmt, deleteScoreStmt;
// This class should not be instantiated.
private ScoreDB() {}
/**
* Initializes the database connection.
*/
public static void init(Configuration config) {
public static void init() {
// create a database connection
connection = DBController.createConnection(config.SCORE_DB.getPath());
if (connection == null)
@@ -124,7 +122,7 @@ public class ScoreDB {
// TODO: extra playerName checks not needed if name is guaranteed not null
);
} catch (SQLException e) {
ErrorHandler.error("Failed to prepare score statements.", e).show();
explode("Failed to prepare score statements.", e, DEFAULT_OPTIONS);
}
}
@@ -157,7 +155,7 @@ public class ScoreDB {
sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', %d)", DATABASE_VERSION);
stmt.executeUpdate(sql);
} catch (SQLException e) {
ErrorHandler.error("Could not create score database.", e).show();
explode("Could not create score database.", e, DEFAULT_OPTIONS);
}
}
@@ -209,7 +207,7 @@ public class ScoreDB {
ps.close();
}
} catch (SQLException e) {
ErrorHandler.error("Failed to update score database.", e).show();
explode("Failed to update score database.", e, DEFAULT_OPTIONS);
}
}
@@ -227,7 +225,7 @@ public class ScoreDB {
insertStmt.setString(19, data.playerName);
insertStmt.executeUpdate();
} catch (SQLException e) {
ErrorHandler.error("Failed to save score to database.", e).show();
explode("Failed to save score to database.", e, DEFAULT_OPTIONS);
}
}
@@ -247,7 +245,7 @@ public class ScoreDB {
deleteScoreStmt.setString(21, data.playerName);
deleteScoreStmt.executeUpdate();
} catch (SQLException e) {
ErrorHandler.error("Failed to delete score from database.", e).show();
explode("Failed to delete score from database.", e, DEFAULT_OPTIONS);
}
}
@@ -267,7 +265,7 @@ public class ScoreDB {
deleteSongStmt.setString(5, beatmap.version);
deleteSongStmt.executeUpdate();
} catch (SQLException e) {
ErrorHandler.error("Failed to delete scores from database.", e).show();
explode("Failed to delete scores from database.", e, DEFAULT_OPTIONS);
}
}
@@ -335,7 +333,7 @@ public class ScoreDB {
}
rs.close();
} catch (SQLException e) {
ErrorHandler.error("Failed to read scores from database.", e).show();
explode("Failed to read scores from database.", e, DEFAULT_OPTIONS);
return null;
}
return getSortedArray(list);
@@ -377,7 +375,7 @@ public class ScoreDB {
map.put(version, getSortedArray(list));
rs.close();
} catch (SQLException e) {
ErrorHandler.error("Failed to read scores from database.", e).show();
explode("Failed to read scores from database.", e, DEFAULT_OPTIONS);
return null;
}
return map;
@@ -406,7 +404,7 @@ public class ScoreDB {
connection.close();
connection = null;
} catch (SQLException e) {
ErrorHandler.error("Failed to close score database.", e).show();
explode("Failed to close score database.", e, DEFAULT_OPTIONS);
}
}
}

View File

@@ -35,9 +35,10 @@ import java.nio.file.StandardCopyOption;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BubNotifListener;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* File download.
*/
@@ -144,7 +145,7 @@ public class Download {
this.url = new URL(remoteURL);
} catch (MalformedURLException e) {
this.status = Status.ERROR;
ErrorHandler.error(String.format("Bad download URL: '%s'", remoteURL), e).show();
explode(String.format("Bad download URL: '%s'", remoteURL), e, DEFAULT_OPTIONS);
return;
}
this.localPath = localPath;
@@ -421,7 +422,7 @@ public class Download {
}
} catch (IOException e) {
this.status = Status.ERROR;
ErrorHandler.error("Failed to cancel download.", e).show();
explode("Failed to cancel download.", e, DEFAULT_OPTIONS);
}
}
}

View File

@@ -36,9 +36,9 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.Constants;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BarNotifListener;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
@@ -291,7 +291,7 @@ public class Updater {
pb.start();
} catch (IOException e) {
status = Status.INTERNAL_ERROR;
ErrorHandler.error("Failed to start new process.", e).show();
explode("Failed to start new process.", e, DEFAULT_OPTIONS);
}
}
}

View File

@@ -33,7 +33,8 @@ import java.util.Date;
import org.json.JSONArray;
import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Download server: http://bloodcat.com/osu/
@@ -95,7 +96,7 @@ public class BloodcatServer extends DownloadServer {
resultCount++;
this.totalResults = resultCount;
} catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
explode(String.format("Problem loading result list for query '%s'.", query), e, DEFAULT_OPTIONS);
}
return nodes;
}

View File

@@ -29,7 +29,8 @@ import java.net.URLEncoder;
import org.json.JSONArray;
import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Download server: https://osu.hexide.com/
@@ -126,7 +127,7 @@ public class HexideServer extends DownloadServer {
// all results at once; this approach just gets pagination correct.
this.totalResults = arr.length() + resultIndex;
} catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
explode(String.format("Problem loading result list for query '%s'.", query), e, DEFAULT_OPTIONS);
}
return nodes;
}

View File

@@ -29,7 +29,8 @@ import java.net.URLEncoder;
import org.json.JSONArray;
import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Download server: http://osu.mengsky.net/
@@ -98,7 +99,7 @@ public class MengSkyServer extends DownloadServer {
}
this.totalResults = resultCount;
} catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
explode(String.format("Problem loading result list for query '%s'.", query), e, DEFAULT_OPTIONS);
}
return nodes;
}

View File

@@ -20,7 +20,6 @@ package itdelatrisu.opsu.downloads.servers;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.DownloadNode;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -32,6 +31,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Download server: http://osu.uu.gl/
*/
@@ -118,7 +119,7 @@ public class MnetworkServer extends DownloadServer {
// store total result count
this.totalResults = nodes.length;
} catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
explode(String.format("Problem loading result list for query '%s'.", query), e, DEFAULT_OPTIONS);
}
return nodes;
}

View File

@@ -35,7 +35,8 @@ import java.util.TimeZone;
import org.json.JSONArray;
import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Download server: http://loli.al/
@@ -121,7 +122,7 @@ public class OsuMirrorServer extends DownloadServer {
else
this.totalResults = maxServerID;
} catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
explode(String.format("Problem loading result list for query '%s'.", query), e, DEFAULT_OPTIONS);
}
return nodes;
}

View File

@@ -33,7 +33,8 @@ import java.util.Iterator;
import java.util.List;
import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
/**
* Download server: http://osu.yas-online.net/
@@ -112,7 +113,8 @@ public class YaSOnlineServer extends DownloadServer {
String downloadLink = item.getString("downloadLink");
return String.format(DOWNLOAD_FETCH_URL, downloadLink);
} catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem retrieving download URL for beatmap '%d'.", beatmapSetID), e).show();
explode(String.format("Problem retrieving download URL for beatmap '%d'.", beatmapSetID), e,
DEFAULT_OPTIONS);
return null;
} finally {
Utils.setSSLCertValidation(true);
@@ -184,7 +186,7 @@ public class YaSOnlineServer extends DownloadServer {
else
this.totalResults = maxServerID;
} catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
explode(String.format("Problem loading result list for query '%s'.", query), e, DEFAULT_OPTIONS);
} finally {
Utils.setSSLCertValidation(true);
}

View File

@@ -44,9 +44,9 @@ import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
import org.newdawn.slick.util.Log;
import lzma.streams.LzmaOutputStream;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BubNotifListener;
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
@@ -344,7 +344,7 @@ public class Replay {
compressedOut.write(bytes);
} catch (IOException e) {
// possible OOM: https://github.com/jponge/lzma-java/issues/9
ErrorHandler.error("LZMA compression failed (possible out-of-memory error).", e).show();
explode("LZMA compression failed (possible out-of-memory error).", e, DEFAULT_OPTIONS);
}
compressedOut.close();
bout.close();
@@ -358,7 +358,7 @@ public class Replay {
writer.close();
} catch (IOException e) {
ErrorHandler.error("Could not save replay data.", e).show();
explode("Could not save replay data.", e, DEFAULT_OPTIONS);
}
}
}.start();