refactor errorhandler
This commit is contained in:
parent
a5efe7e649
commit
08f5bfc27f
|
@ -869,7 +869,8 @@ public enum GameImage {
|
||||||
skinImages = null;
|
skinImages = null;
|
||||||
}
|
}
|
||||||
} catch (SlickException e) {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,8 @@ import org.newdawn.slick.util.Log;
|
||||||
import com.sun.jna.platform.FileUtils;
|
import com.sun.jna.platform.FileUtils;
|
||||||
import yugecin.opsudance.core.NotNull;
|
import yugecin.opsudance.core.NotNull;
|
||||||
import yugecin.opsudance.core.Nullable;
|
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.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -313,7 +312,7 @@ public class Utils {
|
||||||
try {
|
try {
|
||||||
json = new JSONObject(s);
|
json = new JSONObject(s);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
ErrorHandler.error("Failed to create JSON object.", e).show();
|
explode("Failed to create JSON object.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
|
@ -332,7 +331,7 @@ public class Utils {
|
||||||
try {
|
try {
|
||||||
json = new JSONArray(s);
|
json = new JSONArray(s);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
ErrorHandler.error("Failed to create JSON array.", e).show();
|
explode("Failed to create JSON array.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
|
@ -374,7 +373,7 @@ public class Utils {
|
||||||
result.append(String.format("%02x", b));
|
result.append(String.format("%02x", b));
|
||||||
return result.toString();
|
return result.toString();
|
||||||
} catch (NoSuchAlgorithmException | IOException e) {
|
} catch (NoSuchAlgorithmException | IOException e) {
|
||||||
ErrorHandler.error("Failed to calculate MD5 hash.", e).show();
|
explode("Failed to calculate MD5 hash.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package itdelatrisu.opsu.audio;
|
package itdelatrisu.opsu.audio;
|
||||||
|
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -14,6 +12,8 @@ import javax.sound.sampled.FloatControl;
|
||||||
import javax.sound.sampled.LineListener;
|
import javax.sound.sampled.LineListener;
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of Clip that allows playing multiple copies of a Clip simultaneously.
|
* Extension of Clip that allows playing multiple copies of a Clip simultaneously.
|
||||||
* http://stackoverflow.com/questions/1854616/
|
* http://stackoverflow.com/questions/1854616/
|
||||||
|
@ -194,7 +194,8 @@ public class MultiClip {
|
||||||
try {
|
try {
|
||||||
audioIn.close();
|
audioIn.close();
|
||||||
} catch (IOException e) {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,10 +45,10 @@ import org.newdawn.slick.openal.SoundStore;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import org.tritonus.share.sampled.file.TAudioFileFormat;
|
import org.tritonus.share.sampled.file.TAudioFileFormat;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.events.BarNotifListener;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BubNotifListener;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -576,7 +576,7 @@ public class MusicController {
|
||||||
|
|
||||||
player = null;
|
player = null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorHandler.error("Failed to destroy OpenAL.", e).show();
|
explode("Failed to destroy OpenAL.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,12 @@ import javax.sound.sampled.LineUnavailableException;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
import org.newdawn.slick.SlickException;
|
import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.events.BarNotifListener;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
import yugecin.opsudance.events.BubNotifListener;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.options.Configuration;
|
import yugecin.opsudance.options.Configuration;
|
||||||
import yugecin.opsudance.skinning.SkinService;
|
import yugecin.opsudance.skinning.SkinService;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ public class SoundController {
|
||||||
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
|
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
|
||||||
return loadClip(ref, audioIn, isMP3);
|
return loadClip(ref, audioIn, isMP3);
|
||||||
} catch (Exception e) {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ public class SoundController {
|
||||||
try {
|
try {
|
||||||
clip.start(volume, listener);
|
clip.start(volume, listener);
|
||||||
} catch (LineUnavailableException e) {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,10 @@ import itdelatrisu.opsu.ui.Colors;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.Nullable;
|
import yugecin.opsudance.core.Nullable;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.events.BubNotifListener;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.skinning.SkinService;
|
import yugecin.opsudance.skinning.SkinService;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ public class BeatmapParser {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logAndShowErrorNotification(e, "Failed to read file '%s'.", map.getFile().getAbsolutePath());
|
logAndShowErrorNotification(e, "Failed to read file '%s'.", map.getFile().getAbsolutePath());
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} 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
|
// retry without MD5
|
||||||
hasNoMD5Algorithm = true;
|
hasNoMD5Algorithm = true;
|
||||||
|
@ -653,7 +653,7 @@ public class BeatmapParser {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logAndShowErrorNotification(e, "Failed to read file '%s'.", file.getAbsolutePath());
|
logAndShowErrorNotification(e, "Failed to read file '%s'.", file.getAbsolutePath());
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} 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
|
// retry without MD5
|
||||||
hasNoMD5Algorithm = true;
|
hasNoMD5Algorithm = true;
|
||||||
|
@ -811,8 +811,9 @@ public class BeatmapParser {
|
||||||
|
|
||||||
// check that all objects were parsed
|
// check that all objects were parsed
|
||||||
if (objectIndex != beatmap.objects.length)
|
if (objectIndex != beatmap.objects.length)
|
||||||
ErrorHandler.error(String.format("Parsed %d objects for beatmap '%s', %d objects expected.",
|
explode(String.format("Parsed %d objects for beatmap '%s', %d objects expected.",
|
||||||
objectIndex, beatmap.toString(), beatmap.objects.length), new Exception("no")).show();
|
objectIndex, beatmap.toString(), beatmap.objects.length), new Exception("no"),
|
||||||
|
DEFAULT_OPTIONS);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logAndShowErrorNotification(e, "Failed to read file '%s'.",
|
logAndShowErrorNotification(e, "Failed to read file '%s'.",
|
||||||
beatmap.getFile().getAbsolutePath());
|
beatmap.getFile().getAbsolutePath());
|
||||||
|
|
|
@ -33,8 +33,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.newdawn.slick.util.Log;
|
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.
|
* Handles connections and queries with the cached beatmap database.
|
||||||
|
@ -89,17 +90,10 @@ public class BeatmapDB {
|
||||||
/** Current size of beatmap cache table. */
|
/** Current size of beatmap cache table. */
|
||||||
private static int cacheSize = -1;
|
private static int cacheSize = -1;
|
||||||
|
|
||||||
// This class should not be instantiated.
|
|
||||||
private BeatmapDB() {}
|
|
||||||
|
|
||||||
private static Configuration config; // TODO
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the database connection.
|
* Initializes the database connection.
|
||||||
*/
|
*/
|
||||||
public static void init(Configuration config) {
|
public static void init() {
|
||||||
BeatmapDB.config = config;
|
|
||||||
|
|
||||||
// create a database connection
|
// create a database connection
|
||||||
connection = DBController.createConnection(config.BEATMAP_DB.getPath());
|
connection = DBController.createConnection(config.BEATMAP_DB.getPath());
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
|
@ -115,7 +109,7 @@ public class BeatmapDB {
|
||||||
try {
|
try {
|
||||||
updateSizeStmt = connection.prepareStatement("REPLACE INTO info (key, value) VALUES ('size', ?)");
|
updateSizeStmt = connection.prepareStatement("REPLACE INTO info (key, value) VALUES ('size', ?)");
|
||||||
} catch (SQLException e) {
|
} 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
|
// retrieve the cache size
|
||||||
|
@ -137,7 +131,7 @@ public class BeatmapDB {
|
||||||
updatePlayStatsStmt = connection.prepareStatement("UPDATE beatmaps SET playCount = ?, lastPlayed = ? WHERE dir = ? AND file = ?");
|
updatePlayStatsStmt = connection.prepareStatement("UPDATE beatmaps SET playCount = ?, lastPlayed = ? WHERE dir = ? AND file = ?");
|
||||||
setFavoriteStmt = connection.prepareStatement("UPDATE beatmaps SET favorite = ? WHERE dir = ? AND file = ?");
|
setFavoriteStmt = connection.prepareStatement("UPDATE beatmaps SET favorite = ? WHERE dir = ? AND file = ?");
|
||||||
} catch (SQLException e) {
|
} 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);
|
sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', '%s')", DATABASE_VERSION);
|
||||||
stmt.executeUpdate(sql);
|
stmt.executeUpdate(sql);
|
||||||
} catch (SQLException e) {
|
} 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();
|
ps.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} 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();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
} 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.setString(1, Integer.toString(Math.max(cacheSize, 0)));
|
||||||
updateSizeStmt.executeUpdate();
|
updateSizeStmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} 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;
|
cacheSize = 0;
|
||||||
updateCacheSize();
|
updateCacheSize();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ErrorHandler.error("Could not drop beatmap database.", e).show();
|
explode("Could not drop beatmap database.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
createDatabase();
|
createDatabase();
|
||||||
}
|
}
|
||||||
|
@ -296,7 +290,7 @@ public class BeatmapDB {
|
||||||
cacheSize += insertStmt.executeUpdate();
|
cacheSize += insertStmt.executeUpdate();
|
||||||
updateCacheSize();
|
updateCacheSize();
|
||||||
} catch (SQLException e) {
|
} 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
|
// update cache size
|
||||||
updateCacheSize();
|
updateCacheSize();
|
||||||
} catch (SQLException e) {
|
} 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();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
} 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();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
} 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();
|
rs.close();
|
||||||
return map;
|
return map;
|
||||||
} catch (SQLException e) {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -621,7 +615,7 @@ public class BeatmapDB {
|
||||||
cacheSize -= deleteMapStmt.executeUpdate();
|
cacheSize -= deleteMapStmt.executeUpdate();
|
||||||
updateCacheSize();
|
updateCacheSize();
|
||||||
} catch (SQLException e) {
|
} 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();
|
cacheSize -= deleteGroupStmt.executeUpdate();
|
||||||
updateCacheSize();
|
updateCacheSize();
|
||||||
} catch (SQLException e) {
|
} 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.setString(3, beatmap.getFile().getName());
|
||||||
setStarsStmt.executeUpdate();
|
setStarsStmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ErrorHandler.error(String.format("Failed to save star rating '%.4f' for beatmap '%s' in database.",
|
explode(String.format("Failed to save star rating '%.4f' for beatmap '%s' in database.",
|
||||||
beatmap.starRating, beatmap.toString()), e).show();
|
beatmap.starRating, beatmap.toString()), e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,8 +670,8 @@ public class BeatmapDB {
|
||||||
updatePlayStatsStmt.setString(4, beatmap.getFile().getName());
|
updatePlayStatsStmt.setString(4, beatmap.getFile().getName());
|
||||||
updatePlayStatsStmt.executeUpdate();
|
updatePlayStatsStmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ErrorHandler.error(String.format("Failed to update play statistics for beatmap '%s' in database.",
|
explode(String.format("Failed to update play statistics for beatmap '%s' in database.",
|
||||||
beatmap.toString()), e).show();
|
beatmap.toString()), e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,8 +689,8 @@ public class BeatmapDB {
|
||||||
setFavoriteStmt.setString(3, beatmap.getFile().getName());
|
setFavoriteStmt.setString(3, beatmap.getFile().getName());
|
||||||
setFavoriteStmt.executeUpdate();
|
setFavoriteStmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ErrorHandler.error(String.format("Failed to update favorite status for beatmap '%s' in database.",
|
explode(String.format("Failed to update favorite status for beatmap '%s' in database.",
|
||||||
beatmap.toString()), e).show();
|
beatmap.toString()), e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,7 +710,7 @@ public class BeatmapDB {
|
||||||
connection.close();
|
connection.close();
|
||||||
connection = null;
|
connection = null;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ErrorHandler.error("Failed to close beatmap database.", e).show();
|
explode("Failed to close beatmap database.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,12 @@
|
||||||
|
|
||||||
package itdelatrisu.opsu.db;
|
package itdelatrisu.opsu.db;
|
||||||
|
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.options.Configuration;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database controller.
|
* Database controller.
|
||||||
*/
|
*/
|
||||||
|
@ -35,17 +34,17 @@ public class DBController {
|
||||||
/**
|
/**
|
||||||
* Initializes all databases.
|
* Initializes all databases.
|
||||||
*/
|
*/
|
||||||
public static void init(Configuration config) {
|
public static void init() {
|
||||||
// load the sqlite-JDBC driver using the current class loader
|
// load the sqlite-JDBC driver using the current class loader
|
||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
} catch (ClassNotFoundException e) {
|
} 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
|
// initialize the databases
|
||||||
BeatmapDB.init(config);
|
BeatmapDB.init();
|
||||||
ScoreDB.init(config);
|
ScoreDB.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +65,7 @@ public class DBController {
|
||||||
return DriverManager.getConnection(String.format("jdbc:sqlite:%s", path));
|
return DriverManager.getConnection(String.format("jdbc:sqlite:%s", path));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// if the error message is "out of memory", it probably means no database file is found
|
// 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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@ package itdelatrisu.opsu.db;
|
||||||
|
|
||||||
import itdelatrisu.opsu.ScoreData;
|
import itdelatrisu.opsu.ScoreData;
|
||||||
import itdelatrisu.opsu.beatmap.Beatmap;
|
import itdelatrisu.opsu.beatmap.Beatmap;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.options.Configuration;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
@ -36,6 +34,9 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.
|
* Handles connections and queries with the scores database.
|
||||||
*/
|
*/
|
||||||
|
@ -77,13 +78,10 @@ public class ScoreDB {
|
||||||
/** Score deletion statement. */
|
/** Score deletion statement. */
|
||||||
private static PreparedStatement deleteSongStmt, deleteScoreStmt;
|
private static PreparedStatement deleteSongStmt, deleteScoreStmt;
|
||||||
|
|
||||||
// This class should not be instantiated.
|
|
||||||
private ScoreDB() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the database connection.
|
* Initializes the database connection.
|
||||||
*/
|
*/
|
||||||
public static void init(Configuration config) {
|
public static void init() {
|
||||||
// create a database connection
|
// create a database connection
|
||||||
connection = DBController.createConnection(config.SCORE_DB.getPath());
|
connection = DBController.createConnection(config.SCORE_DB.getPath());
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
|
@ -124,7 +122,7 @@ public class ScoreDB {
|
||||||
// TODO: extra playerName checks not needed if name is guaranteed not null
|
// TODO: extra playerName checks not needed if name is guaranteed not null
|
||||||
);
|
);
|
||||||
} catch (SQLException e) {
|
} 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);
|
sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', %d)", DATABASE_VERSION);
|
||||||
stmt.executeUpdate(sql);
|
stmt.executeUpdate(sql);
|
||||||
} catch (SQLException e) {
|
} 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();
|
ps.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} 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.setString(19, data.playerName);
|
||||||
insertStmt.executeUpdate();
|
insertStmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} 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.setString(21, data.playerName);
|
||||||
deleteScoreStmt.executeUpdate();
|
deleteScoreStmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} 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.setString(5, beatmap.version);
|
||||||
deleteSongStmt.executeUpdate();
|
deleteSongStmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} 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();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
} 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 null;
|
||||||
}
|
}
|
||||||
return getSortedArray(list);
|
return getSortedArray(list);
|
||||||
|
@ -377,7 +375,7 @@ public class ScoreDB {
|
||||||
map.put(version, getSortedArray(list));
|
map.put(version, getSortedArray(list));
|
||||||
rs.close();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
} 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 null;
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
|
@ -406,7 +404,7 @@ public class ScoreDB {
|
||||||
connection.close();
|
connection.close();
|
||||||
connection = null;
|
connection = null;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
ErrorHandler.error("Failed to close score database.", e).show();
|
explode("Failed to close score database.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,10 @@ import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.events.BubNotifListener;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File download.
|
* File download.
|
||||||
*/
|
*/
|
||||||
|
@ -144,7 +145,7 @@ public class Download {
|
||||||
this.url = new URL(remoteURL);
|
this.url = new URL(remoteURL);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
this.status = Status.ERROR;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
this.localPath = localPath;
|
this.localPath = localPath;
|
||||||
|
@ -421,7 +422,7 @@ public class Download {
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
this.status = Status.ERROR;
|
this.status = Status.ERROR;
|
||||||
ErrorHandler.error("Failed to cancel download.", e).show();
|
explode("Failed to cancel download.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,9 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import yugecin.opsudance.core.Constants;
|
import yugecin.opsudance.core.Constants;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.events.BarNotifListener;
|
import yugecin.opsudance.events.BarNotifListener;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,7 +291,7 @@ public class Updater {
|
||||||
pb.start();
|
pb.start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
status = Status.INTERNAL_ERROR;
|
status = Status.INTERNAL_ERROR;
|
||||||
ErrorHandler.error("Failed to start new process.", e).show();
|
explode("Failed to start new process.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ import java.util.Date;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download server: http://bloodcat.com/osu/
|
* Download server: http://bloodcat.com/osu/
|
||||||
|
@ -95,7 +96,7 @@ public class BloodcatServer extends DownloadServer {
|
||||||
resultCount++;
|
resultCount++;
|
||||||
this.totalResults = resultCount;
|
this.totalResults = resultCount;
|
||||||
} catch (MalformedURLException | UnsupportedEncodingException e) {
|
} 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;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ import java.net.URLEncoder;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download server: https://osu.hexide.com/
|
* 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.
|
// all results at once; this approach just gets pagination correct.
|
||||||
this.totalResults = arr.length() + resultIndex;
|
this.totalResults = arr.length() + resultIndex;
|
||||||
} catch (MalformedURLException | UnsupportedEncodingException e) {
|
} 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;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ import java.net.URLEncoder;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download server: http://osu.mengsky.net/
|
* Download server: http://osu.mengsky.net/
|
||||||
|
@ -98,7 +99,7 @@ public class MengSkyServer extends DownloadServer {
|
||||||
}
|
}
|
||||||
this.totalResults = resultCount;
|
this.totalResults = resultCount;
|
||||||
} catch (MalformedURLException | UnsupportedEncodingException e) {
|
} 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;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package itdelatrisu.opsu.downloads.servers;
|
||||||
|
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.downloads.DownloadNode;
|
import itdelatrisu.opsu.downloads.DownloadNode;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
@ -32,6 +31,8 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download server: http://osu.uu.gl/
|
* Download server: http://osu.uu.gl/
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +119,7 @@ public class MnetworkServer extends DownloadServer {
|
||||||
// store total result count
|
// store total result count
|
||||||
this.totalResults = nodes.length;
|
this.totalResults = nodes.length;
|
||||||
} catch (MalformedURLException | UnsupportedEncodingException e) {
|
} 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;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ import java.util.TimeZone;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download server: http://loli.al/
|
* Download server: http://loli.al/
|
||||||
|
@ -121,7 +122,7 @@ public class OsuMirrorServer extends DownloadServer {
|
||||||
else
|
else
|
||||||
this.totalResults = maxServerID;
|
this.totalResults = maxServerID;
|
||||||
} catch (MalformedURLException | UnsupportedEncodingException e) {
|
} 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;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download server: http://osu.yas-online.net/
|
* Download server: http://osu.yas-online.net/
|
||||||
|
@ -112,7 +113,8 @@ public class YaSOnlineServer extends DownloadServer {
|
||||||
String downloadLink = item.getString("downloadLink");
|
String downloadLink = item.getString("downloadLink");
|
||||||
return String.format(DOWNLOAD_FETCH_URL, downloadLink);
|
return String.format(DOWNLOAD_FETCH_URL, downloadLink);
|
||||||
} catch (MalformedURLException | UnsupportedEncodingException e) {
|
} 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;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
Utils.setSSLCertValidation(true);
|
Utils.setSSLCertValidation(true);
|
||||||
|
@ -184,7 +186,7 @@ public class YaSOnlineServer extends DownloadServer {
|
||||||
else
|
else
|
||||||
this.totalResults = maxServerID;
|
this.totalResults = maxServerID;
|
||||||
} catch (MalformedURLException | UnsupportedEncodingException e) {
|
} 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 {
|
} finally {
|
||||||
Utils.setSSLCertValidation(true);
|
Utils.setSSLCertValidation(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,9 @@ import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
|
|
||||||
import lzma.streams.LzmaOutputStream;
|
import lzma.streams.LzmaOutputStream;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
import yugecin.opsudance.events.BubNotifListener;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -344,7 +344,7 @@ public class Replay {
|
||||||
compressedOut.write(bytes);
|
compressedOut.write(bytes);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// possible OOM: https://github.com/jponge/lzma-java/issues/9
|
// 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();
|
compressedOut.close();
|
||||||
bout.close();
|
bout.close();
|
||||||
|
@ -358,7 +358,7 @@ public class Replay {
|
||||||
|
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ErrorHandler.error("Could not save replay data.", e).show();
|
explode("Could not save replay data.", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|
|
@ -22,13 +22,13 @@ import itdelatrisu.opsu.beatmap.BeatmapWatchService;
|
||||||
import itdelatrisu.opsu.db.DBController;
|
import itdelatrisu.opsu.db.DBController;
|
||||||
import itdelatrisu.opsu.downloads.DownloadList;
|
import itdelatrisu.opsu.downloads.DownloadList;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
import static yugecin.opsudance.core.Entrypoint.sout;
|
import static yugecin.opsudance.core.Entrypoint.sout;
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
|
@ -75,7 +75,7 @@ public class OpsuDance {
|
||||||
displayContainer.setup();
|
displayContainer.setup();
|
||||||
displayContainer.resume();
|
displayContainer.resume();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorHandler.error("could not initialize GL", e).allowTerminate().preventContinue().show();
|
explode("could not initialize GL", e, ALLOW_TERMINATE | PREVENT_CONTINUE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Exception caughtException = null;
|
Exception caughtException = null;
|
||||||
|
@ -86,12 +86,12 @@ public class OpsuDance {
|
||||||
}
|
}
|
||||||
displayContainer.teardown();
|
displayContainer.teardown();
|
||||||
displayContainer.pause();
|
displayContainer.pause();
|
||||||
return caughtException != null && ErrorHandler.error("update/render error", caughtException).allowTerminate().show().shouldIgnoreAndContinue();
|
return caughtException != null && explode("update/render error", caughtException, ALLOW_TERMINATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDatabase() {
|
private void initDatabase() {
|
||||||
try {
|
try {
|
||||||
DBController.init(config);
|
DBController.init();
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
errorAndExit("Could not initialize database.", e);
|
errorAndExit("Could not initialize database.", e);
|
||||||
}
|
}
|
||||||
|
@ -146,13 +146,8 @@ public class OpsuDance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void errorAndExit(String errstr) {
|
|
||||||
ErrorHandler.error(errstr, new Throwable()).allowTerminate().preventContinue().show();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void errorAndExit(String errstr, Throwable cause) {
|
private void errorAndExit(String errstr, Throwable cause) {
|
||||||
ErrorHandler.error(errstr, cause).preventContinue().show();
|
explode(errstr, cause, PREVENT_CONTINUE);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -466,6 +466,10 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
|
||||||
public void writeErrorDump(StringWriter dump) {
|
public void writeErrorDump(StringWriter dump) {
|
||||||
dump.append("> DisplayContainer dump\n");
|
dump.append("> DisplayContainer dump\n");
|
||||||
dump.append("OpenGL version: ").append(glVersion).append( "(").append(glVendor).append(")\n");
|
dump.append("OpenGL version: ").append(glVersion).append( "(").append(glVendor).append(")\n");
|
||||||
|
if (state == null) {
|
||||||
|
dump.append("state is null!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
state.writeErrorDump(dump);
|
state.writeErrorDump(dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ package yugecin.opsudance.core.errorhandling;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.core.Constants;
|
import yugecin.opsudance.core.Constants;
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
|
||||||
import yugecin.opsudance.options.Configuration;
|
|
||||||
import yugecin.opsudance.utils.MiscUtils;
|
import yugecin.opsudance.utils.MiscUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -36,80 +34,52 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* based on itdelatrisu.opsu.ErrorHandler
|
* based on itdelatrisu.opsu.ErrorHandler
|
||||||
*/
|
*/
|
||||||
public class ErrorHandler {
|
public class ErrorHandler {
|
||||||
|
|
||||||
private static ErrorHandler instance;
|
public final static int DEFAULT_OPTIONS = 0;
|
||||||
|
public final static int PREVENT_CONTINUE = 1;
|
||||||
private final Configuration config;
|
public final static int PREVENT_REPORT = 2;
|
||||||
private final DisplayContainer displayContainer;
|
public final static int ALLOW_TERMINATE = 4;
|
||||||
|
|
||||||
private String customMessage;
|
|
||||||
private Throwable cause;
|
|
||||||
private String errorDump;
|
|
||||||
private String messageBody;
|
|
||||||
|
|
||||||
private boolean preventContinue;
|
|
||||||
private boolean preventReport;
|
|
||||||
private boolean ignoreAndContinue;
|
|
||||||
private boolean allowTerminate;
|
|
||||||
|
|
||||||
public ErrorHandler(DisplayContainer displayContainer, Configuration config) {
|
|
||||||
this.displayContainer = displayContainer;
|
|
||||||
this.config = config;
|
|
||||||
instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ErrorHandler init(String customMessage, Throwable cause) {
|
|
||||||
this.customMessage = customMessage;
|
|
||||||
this.cause = cause;
|
|
||||||
|
|
||||||
|
public static boolean explode(String customMessage, Throwable cause, int flags) {
|
||||||
StringWriter dump = new StringWriter();
|
StringWriter dump = new StringWriter();
|
||||||
try {
|
if (displayContainer == null) {
|
||||||
displayContainer.writeErrorDump(dump);
|
dump.append("displayContainer is null!\n");
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
dump
|
try {
|
||||||
.append("### ")
|
displayContainer.writeErrorDump(dump);
|
||||||
.append(e.getClass().getSimpleName())
|
} catch (Exception e) {
|
||||||
.append(" while creating errordump");
|
dump
|
||||||
e.printStackTrace(new PrintWriter(dump));
|
.append("### ")
|
||||||
|
.append(e.getClass().getSimpleName())
|
||||||
|
.append(" while creating errordump");
|
||||||
|
e.printStackTrace(new PrintWriter(dump));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
errorDump = dump.toString();
|
String errorDump = dump.toString();
|
||||||
|
|
||||||
dump = new StringWriter();
|
dump = new StringWriter();
|
||||||
dump.append(customMessage).append("\n");
|
dump.append(customMessage).append("\n");
|
||||||
cause.printStackTrace(new PrintWriter(dump));
|
cause.printStackTrace(new PrintWriter(dump));
|
||||||
dump.append("\n").append(errorDump);
|
dump.append("\n").append(errorDump);
|
||||||
messageBody = dump.toString();
|
String messageBody = dump.toString();
|
||||||
|
|
||||||
Log.error("====== start unhandled exception dump");
|
Log.error("====== start unhandled exception dump");
|
||||||
Log.error(messageBody);
|
Log.error(messageBody);
|
||||||
Log.error("====== end unhandled exception dump");
|
Log.error("====== end unhandled exception dump");
|
||||||
return this;
|
|
||||||
|
int result = show(messageBody, customMessage, cause, errorDump, flags);
|
||||||
|
|
||||||
|
return (flags & ALLOW_TERMINATE) == 0 || result == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ErrorHandler error(String message, Throwable cause) {
|
private static int show(final String messageBody, final String customMessage, final Throwable cause,
|
||||||
return instance.init(message, cause);
|
final String errorDump, final int flags) {
|
||||||
}
|
|
||||||
|
|
||||||
public ErrorHandler preventReport() {
|
|
||||||
preventReport = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ErrorHandler allowTerminate() {
|
|
||||||
allowTerminate = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ErrorHandler preventContinue() {
|
|
||||||
preventContinue = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ErrorHandler show() {
|
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -119,7 +89,7 @@ public class ErrorHandler {
|
||||||
String title = "opsu!dance error - " + customMessage;
|
String title = "opsu!dance error - " + customMessage;
|
||||||
|
|
||||||
String messageText = "opsu!dance has encountered an error.";
|
String messageText = "opsu!dance has encountered an error.";
|
||||||
if (!preventReport) {
|
if ((flags & PREVENT_REPORT) == 0) {
|
||||||
messageText += " Please report this!";
|
messageText += " Please report this!";
|
||||||
}
|
}
|
||||||
JLabel message = new JLabel(messageText);
|
JLabel message = new JLabel(messageText);
|
||||||
|
@ -133,12 +103,27 @@ public class ErrorHandler {
|
||||||
textArea.setWrapStyleWord(true);
|
textArea.setWrapStyleWord(true);
|
||||||
textArea.setText(messageBody);
|
textArea.setText(messageBody);
|
||||||
|
|
||||||
Object[] messageComponents = new Object[] { message, new JScrollPane(textArea), createViewLogButton(), createReportButton() };
|
ActionListener reportAction = new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
try {
|
||||||
|
URI url = createGithubIssueUrl(customMessage, cause, errorDump);
|
||||||
|
Desktop.getDesktop().browse(url);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.warn("Could not open browser to report issue", e);
|
||||||
|
JOptionPane.showMessageDialog(null, "whoops could not launch a browser",
|
||||||
|
"errorception", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Object[] messageComponents = new Object[] { message, new JScrollPane(textArea), createViewLogButton(),
|
||||||
|
createReportButton(flags, reportAction) };
|
||||||
|
|
||||||
String[] buttons;
|
String[] buttons;
|
||||||
if (!allowTerminate && !preventContinue) {
|
if ((flags & (ALLOW_TERMINATE | PREVENT_CONTINUE)) == 0) {
|
||||||
buttons = new String[] { "Ignore & continue" };
|
buttons = new String[] { "Ignore & continue" };
|
||||||
} else if (preventContinue) {
|
} else if ((flags & PREVENT_CONTINUE) == 0) {
|
||||||
buttons = new String[] { "Terminate" };
|
buttons = new String[] { "Terminate" };
|
||||||
} else {
|
} else {
|
||||||
buttons = new String[] { "Terminate", "Ignore & continue" };
|
buttons = new String[] { "Terminate", "Ignore & continue" };
|
||||||
|
@ -148,52 +133,46 @@ public class ErrorHandler {
|
||||||
frame.setUndecorated(true);
|
frame.setUndecorated(true);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
int result = JOptionPane.showOptionDialog(frame,
|
int result = JOptionPane.showOptionDialog(frame, messageComponents, title, JOptionPane.DEFAULT_OPTION,
|
||||||
messageComponents,
|
JOptionPane.ERROR_MESSAGE, null, buttons, buttons[buttons.length - 1]);
|
||||||
title,
|
|
||||||
JOptionPane.DEFAULT_OPTION,
|
|
||||||
JOptionPane.ERROR_MESSAGE,
|
|
||||||
null,
|
|
||||||
buttons,
|
|
||||||
buttons[buttons.length - 1]);
|
|
||||||
ignoreAndContinue = !allowTerminate || result == 1;
|
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
|
|
||||||
return this;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComponent createViewLogButton() {
|
private static JComponent createViewLogButton() {
|
||||||
return createButton("View log", Desktop.Action.OPEN, new ActionListener() {
|
return createButton("View log", Desktop.Action.OPEN, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
try {
|
openLogfile();
|
||||||
Desktop.getDesktop().open(config.LOG_FILE);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.warn("Could not open log file", e);
|
|
||||||
JOptionPane.showMessageDialog(null, "whoops could not open log file", "errorception", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComponent createReportButton() {
|
private static void openLogfile() {
|
||||||
if (preventReport) {
|
if (config == null) {
|
||||||
|
JOptionPane.showMessageDialog(null,
|
||||||
|
"Cannot open logfile, check your opsu! installation folder for .opsu.cfg",
|
||||||
|
"errorception", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().open(config.LOG_FILE);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.warn("Could not open log file", e);
|
||||||
|
JOptionPane.showMessageDialog(null, "whoops could not open log file",
|
||||||
|
"errorception", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JComponent createReportButton(int flags, ActionListener reportAction) {
|
||||||
|
if ((flags & PREVENT_REPORT) > 0) {
|
||||||
return new JLabel();
|
return new JLabel();
|
||||||
}
|
}
|
||||||
return createButton("Report error", Desktop.Action.BROWSE, new ActionListener() {
|
return createButton("Report error", Desktop.Action.BROWSE, reportAction);
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent event) {
|
|
||||||
try {
|
|
||||||
Desktop.getDesktop().browse(createGithubIssueUrl());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.warn("Could not open browser to report issue", e);
|
|
||||||
JOptionPane.showMessageDialog(null, "whoops could not launch a browser", "errorception", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JButton createButton(String buttonText, Desktop.Action action, ActionListener listener) {
|
private static JButton createButton(String buttonText, Desktop.Action action, ActionListener listener) {
|
||||||
JButton button = new JButton(buttonText);
|
JButton button = new JButton(buttonText);
|
||||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(action)) {
|
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(action)) {
|
||||||
button.addActionListener(listener);
|
button.addActionListener(listener);
|
||||||
|
@ -203,7 +182,7 @@ public class ErrorHandler {
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
private URI createGithubIssueUrl() {
|
private static URI createGithubIssueUrl(String customMessage, Throwable cause, String errorDump) {
|
||||||
StringWriter dump = new StringWriter();
|
StringWriter dump = new StringWriter();
|
||||||
|
|
||||||
dump.append(customMessage).append("\n");
|
dump.append(customMessage).append("\n");
|
||||||
|
@ -228,7 +207,8 @@ public class ErrorHandler {
|
||||||
String issueTitle = "";
|
String issueTitle = "";
|
||||||
String issueBody = "";
|
String issueBody = "";
|
||||||
try {
|
try {
|
||||||
issueTitle = URLEncoder.encode("*** Unhandled " + cause.getClass().getSimpleName() + " " + customMessage, "UTF-8");
|
issueTitle = URLEncoder.encode("*** Unhandled " + cause.getClass().getSimpleName() + " " +
|
||||||
|
customMessage, "UTF-8");
|
||||||
issueBody = URLEncoder.encode(truncateGithubIssueBody(dump.toString()), "UTF-8");
|
issueBody = URLEncoder.encode(truncateGithubIssueBody(dump.toString()), "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
Log.warn("URLEncoder failed to encode the auto-filled issue report URL.", e);
|
Log.warn("URLEncoder failed to encode the auto-filled issue report URL.", e);
|
||||||
|
@ -236,7 +216,7 @@ public class ErrorHandler {
|
||||||
return URI.create(String.format(Constants.ISSUES_URL, issueTitle, issueBody));
|
return URI.create(String.format(Constants.ISSUES_URL, issueTitle, issueBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String truncateGithubIssueBody(String body) {
|
private static String truncateGithubIssueBody(String body) {
|
||||||
if (body.replaceAll("[^a-zA-Z+-]", "").length() < 1750) {
|
if (body.replaceAll("[^a-zA-Z+-]", "").length() < 1750) {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
@ -244,8 +224,4 @@ public class ErrorHandler {
|
||||||
return body.substring(0, 1640) + "** TRUNCATED **\n```";
|
return body.substring(0, 1640) + "** TRUNCATED **\n```";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldIgnoreAndContinue() {
|
|
||||||
return ignoreAndContinue;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import itdelatrisu.opsu.ui.Colors;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.events.BubNotifListener;
|
import yugecin.opsudance.events.BubNotifListener;
|
||||||
import yugecin.opsudance.utils.ManifestWrapper;
|
import yugecin.opsudance.utils.ManifestWrapper;
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ import java.util.Date;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
import static yugecin.opsudance.options.Options.*;
|
import static yugecin.opsudance.options.Options.*;
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
|
@ -201,7 +202,8 @@ public class Configuration {
|
||||||
}
|
}
|
||||||
File dir = new File(rootPath, "opsu");
|
File dir = new File(rootPath, "opsu");
|
||||||
if (!dir.isDirectory() && !dir.mkdir()) {
|
if (!dir.isDirectory() && !dir.mkdir()) {
|
||||||
ErrorHandler.error(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath), new Exception("empty")).preventReport().show();
|
explode(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath),
|
||||||
|
new Exception("empty"), PREVENT_REPORT);
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +254,10 @@ public class Configuration {
|
||||||
BubNotifListener.EVENT.make().onBubNotif("Created " + fileName,
|
BubNotifListener.EVENT.make().onBubNotif("Created " + fileName,
|
||||||
Colors.BUB_PURPLE);
|
Colors.BUB_PURPLE);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorHandler.error("Failed to take a screenshot.", e).show();
|
Log.error("Could not take screenshot", e);
|
||||||
|
BubNotifListener.EVENT.make().onBubNotif(
|
||||||
|
"Failed to take a screenshot. See log file for details",
|
||||||
|
Colors.BUB_PURPLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|
|
@ -28,11 +28,12 @@ import org.newdawn.slick.opengl.LoadableImageData;
|
||||||
import org.newdawn.slick.opengl.TGAImageData;
|
import org.newdawn.slick.opengl.TGAImageData;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||||
|
|
||||||
public class GLHelper {
|
public class GLHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,7 +97,7 @@ public class GLHelper {
|
||||||
IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
|
IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
|
||||||
Mouse.setNativeCursor(new Cursor(min, min, min / 2, min / 2, 1, tmp, null));
|
Mouse.setNativeCursor(new Cursor(min, min, min / 2, min / 2, 1, tmp, null));
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
ErrorHandler.error("Cannot hide native cursor", e).show();
|
explode("Cannot hide native cursor", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ public class GLHelper {
|
||||||
try {
|
try {
|
||||||
Mouse.setNativeCursor(null);
|
Mouse.setNativeCursor(null);
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
ErrorHandler.error("Cannot show native cursor", e).show();
|
explode("Cannot show native cursor", e, DEFAULT_OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user