Skip to content

Commit

Permalink
Logging improved
Browse files Browse the repository at this point in the history
  • Loading branch information
MehradN committed Mar 1, 2023
1 parent be46a2d commit e60f1da
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/ir/mehradn/rollback/util/backup/BackupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ private void saveMetadata() {
gson.toJson(this.metadata, writer);
writer.close();
} catch (IOException e) {
Rollback.LOGGER.error("Failed to save the metadata file!");
Rollback.LOGGER.error("Failed to save the metadata file!", e);
throw new RuntimeException(e);
}
}

private void showError(String title, String info) {
Rollback.LOGGER.error(info);
private void showError(String title, String info, Throwable exception) {
Rollback.LOGGER.error(info, exception);
MinecraftClient.getInstance().getToastManager().add(new SystemToast(
SystemToast.Type.WORLD_BACKUP,
Text.translatable(title),
Expand All @@ -87,7 +87,7 @@ public boolean createNormalBackup(LevelSummary summary) {
));
return true;
} catch (IOException e) {
showError("selectWorld.edit.backupFailed", "Failed to create a backup of world!");
showError("selectWorld.edit.backupFailed", "Failed to create a backup of world!", e);
return false;
}
}
Expand All @@ -107,15 +107,15 @@ public boolean createRollbackBackup(MinecraftServer server) {
Rollback.LOGGER.debug("Saving the world...");
boolean f = server.saveAll(true, true, true);
if (!f) {
showError("rollback.createBackup.failed", "Failed to create a backup of world!");
showError("rollback.createBackup.failed", "Failed to create a backup of world!", null);
return false;
}

Rollback.LOGGER.debug("Creating a backup...");
try {
session.createBackup();
} catch (IOException e) {
showError("rollback.createBackup.failed", "Failed to create a backup of world!");
showError("rollback.createBackup.failed", "Failed to create a backup of world!", e);
return false;
}

Expand All @@ -130,7 +130,7 @@ public boolean createRollbackBackup(MinecraftServer server) {
));
Files.move(path1, path2);
} catch (IOException e) {
showError("rollback.createBackup.failed", "Failed to move the backup file!");
showError("rollback.createBackup.failed", "Failed to move the backup file!", e);
return false;
}

Expand All @@ -144,7 +144,7 @@ public boolean createRollbackBackup(MinecraftServer server) {
((GameRendererAccessor)renderer).InvokeUpdateWorldIcon(finalPath);
});
} catch (IOException e) {
showError("rollback.createBackup.failed", "Failed to make an icon for the backup!");
showError("rollback.createBackup.failed", "Failed to make an icon for the backup!", e);
return false;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public boolean deleteBackup(String worldName, int index) {
Files.deleteIfExists(this.rollbackDirectory.resolve(backup.iconPath));
Files.deleteIfExists(this.rollbackDirectory.resolve(backup.backupPath));
} catch (IOException e) {
showError("rollback.deleteBackup.failed", "Failed to delete the files!");
showError("rollback.deleteBackup.failed", "Failed to delete the files!", e);
return false;
}

Expand Down Expand Up @@ -207,7 +207,7 @@ public boolean rollbackTo(RollbackBackup backup) {
try (LevelStorage.Session session = client.getLevelStorage().createSession(backup.worldName)) {
session.deleteSessionLock();
} catch (IOException e) {
showError("rollback.rollback.failed", "Failed to delete the current save!");
showError("rollback.rollback.failed", "Failed to delete the current save!", e);
return false;
}

Expand All @@ -230,7 +230,7 @@ public boolean rollbackTo(RollbackBackup backup) {
}
}
} catch (IOException e) {
showError("rollback.rollback.failed", "Failed to extract the backup to save directory!");
showError("rollback.rollback.failed", "Failed to extract the backup to save directory!", e);
return false;
}

Expand Down

0 comments on commit e60f1da

Please sign in to comment.