Error handling and warning when history can't be loaded
This commit is contained in:
parent
39a9edd1fa
commit
da58fee416
@ -12,6 +12,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class History {
|
||||
@ -100,6 +101,8 @@ public class History {
|
||||
String jsonString = IOUtils.toString(is);
|
||||
JSONArray jsonArray = new JSONArray(jsonString);
|
||||
fromJSON(jsonArray);
|
||||
} catch (JSONException e) {
|
||||
throw new IOException("Failed to load JSON file " + filename + ": " + e.getMessage(), e);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
|
@ -879,6 +879,13 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
||||
HISTORY.fromFile("history.json");
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to load history from file " + historyFile, e);
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" +
|
||||
"Error: " + e.getMessage() + "\n\n" +
|
||||
"Closing RipMe will automatically overwrite the contents of this file,\n" +
|
||||
"so you may want to back the file up before closing RipMe!",
|
||||
"RipMe - history load failure",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user