From 767c7de1634117ca994967caf6a12130ccf3352a Mon Sep 17 00:00:00 2001 From: sk89q Date: Tue, 16 Nov 2010 00:40:19 -0800 Subject: [PATCH] Somewhat improved the bad backup error message. --- src/SnapshotRestore.java | 13 +++++++++++++ src/WorldEditListener.java | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/SnapshotRestore.java b/src/SnapshotRestore.java index 6f896c3af..ac4460190 100644 --- a/src/SnapshotRestore.java +++ b/src/SnapshotRestore.java @@ -49,6 +49,10 @@ public class SnapshotRestore { * Count of the number of chunks that could be loaded for other reasons. */ private ArrayList errorChunks; + /** + * Last error message. + */ + private String lastErrorMessage; /** * Construct the snapshot restore operation. @@ -153,8 +157,10 @@ public class SnapshotRestore { missingChunks.add(chunkPos); } catch (DataException de) { errorChunks.add(chunkPos); + lastErrorMessage = de.getMessage(); } catch (IOException ioe) { errorChunks.add(chunkPos); + lastErrorMessage = ioe.getMessage(); } } } @@ -188,4 +194,11 @@ public class SnapshotRestore { public boolean hadTotalFailure() { return missingChunks.size() + errorChunks.size() == getChunksAffected(); } + + /** + * @return the lastErrorMessage + */ + public String getLastErrorMessage() { + return lastErrorMessage; + } } diff --git a/src/WorldEditListener.java b/src/WorldEditListener.java index e48e3ed97..0b22da345 100644 --- a/src/WorldEditListener.java +++ b/src/WorldEditListener.java @@ -1353,7 +1353,13 @@ public class WorldEditListener extends PluginListener { restore.restore(editSession); if (restore.hadTotalFailure()) { - player.printError("No blocks could be restored. (Bad backup?)"); + String error = restore.getLastErrorMessage(); + if (error != null) { + player.printError("Errors prevented any blocks from being restored."); + player.printError("Last error: " + error); + } else { + player.printError("No chunks could be loaded. (Bad archive?)"); + } } else { player.print(String.format("Restored; %d " + "missing chunks and %d other errors.",