Somewhat improved the bad backup error message.

This commit is contained in:
sk89q 2010-11-16 00:40:19 -08:00
parent a8972e9f04
commit 767c7de163
2 changed files with 20 additions and 1 deletions

View File

@ -49,6 +49,10 @@ public class SnapshotRestore {
* Count of the number of chunks that could be loaded for other reasons. * Count of the number of chunks that could be loaded for other reasons.
*/ */
private ArrayList<Vector2D> errorChunks; private ArrayList<Vector2D> errorChunks;
/**
* Last error message.
*/
private String lastErrorMessage;
/** /**
* Construct the snapshot restore operation. * Construct the snapshot restore operation.
@ -153,8 +157,10 @@ public class SnapshotRestore {
missingChunks.add(chunkPos); missingChunks.add(chunkPos);
} catch (DataException de) { } catch (DataException de) {
errorChunks.add(chunkPos); errorChunks.add(chunkPos);
lastErrorMessage = de.getMessage();
} catch (IOException ioe) { } catch (IOException ioe) {
errorChunks.add(chunkPos); errorChunks.add(chunkPos);
lastErrorMessage = ioe.getMessage();
} }
} }
} }
@ -188,4 +194,11 @@ public class SnapshotRestore {
public boolean hadTotalFailure() { public boolean hadTotalFailure() {
return missingChunks.size() + errorChunks.size() == getChunksAffected(); return missingChunks.size() + errorChunks.size() == getChunksAffected();
} }
/**
* @return the lastErrorMessage
*/
public String getLastErrorMessage() {
return lastErrorMessage;
}
} }

View File

@ -1353,7 +1353,13 @@ public class WorldEditListener extends PluginListener {
restore.restore(editSession); restore.restore(editSession);
if (restore.hadTotalFailure()) { 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 { } else {
player.print(String.format("Restored; %d " player.print(String.format("Restored; %d "
+ "missing chunks and %d other errors.", + "missing chunks and %d other errors.",