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