mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Merge pull request #8669 from kevlahnota/master4
return extra info for save errors
This commit is contained in:
@@ -20,6 +20,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
captureException(e, key, subData);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +34,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -45,6 +47,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -57,6 +60,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -69,6 +73,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -81,6 +86,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -95,6 +101,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
stream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -107,6 +114,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
captureException(e, key, subData);
|
||||
}
|
||||
}
|
||||
@@ -119,6 +127,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
captureException(e, key, subData);
|
||||
}
|
||||
}
|
||||
@@ -132,6 +141,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -147,6 +157,7 @@ public class SaveFileData extends HashMap<String, byte[]> {
|
||||
objStream.flush();
|
||||
put(key, stream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
put("IOException", e.toString().getBytes());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,20 +167,23 @@ public class WorldSave {
|
||||
SaveFileData worldStage = WorldStage.getInstance().save();
|
||||
SaveFileData poiChanges = currentSave.pointOfInterestChanges.save();
|
||||
|
||||
/*if (player.hasError || world.hasError || worldStage.hasError || poiChanges.hasError) {
|
||||
announceError();
|
||||
String message = getExceptionMessage(player, world, worldStage, poiChanges);
|
||||
if (!message.isEmpty()) {
|
||||
announceError(message);
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
SaveFileData mainData = new SaveFileData();
|
||||
mainData.store("player", player);
|
||||
mainData.store("world", world);
|
||||
mainData.store("worldStage", worldStage);
|
||||
mainData.store("pointOfInterestChanges", poiChanges);
|
||||
/*if (mainData.hasError) {
|
||||
announceError();
|
||||
|
||||
if (mainData.readString("IOException") != null) {
|
||||
announceError("Please check forge.log for errors.");
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
header.saveDate = new Date();
|
||||
oos.writeObject(header);
|
||||
oos.writeObject(mainData);
|
||||
@@ -196,8 +199,20 @@ public class WorldSave {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void announceError() {
|
||||
currentSave.player.getCurrentGameStage().setExtraAnnouncement("Error Saving File!\nPlease check forge.log");
|
||||
public String getExceptionMessage(SaveFileData... datas) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
for (SaveFileData data : datas) {
|
||||
String s = data.readString("IOException");
|
||||
if (s != null)
|
||||
message.append(s).append("\n");
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
private void announceError(String message) {
|
||||
currentSave.player.getCurrentGameStage().setExtraAnnouncement("Error Saving File!\n" + message);
|
||||
}
|
||||
|
||||
public void clearChanges() {
|
||||
|
||||
Reference in New Issue
Block a user