diff options
author | Keuin <[email protected]> | 2021-03-10 09:40:59 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2021-03-10 09:40:59 +0800 |
commit | e11c593c7d21d9602fb951f32f6ced8b30a86254 (patch) | |
tree | d36f40b6269f054df3d1b8cd2b3c4a7728c371e8 /src/main/java/com/keuin/kbackupfabric/operation/backup/feedback | |
parent | f8fd155c736c921375a17c7f133a17e40ee89041 (diff) |
print detailed information if incremental backup fail due to an IO exception.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/backup/feedback')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/IncrementalBackupFeedback.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/IncrementalBackupFeedback.java b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/IncrementalBackupFeedback.java index bdd6d88..696ee02 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/IncrementalBackupFeedback.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/IncrementalBackupFeedback.java @@ -3,13 +3,31 @@ package com.keuin.kbackupfabric.operation.backup.feedback; import com.keuin.kbackupfabric.backup.incremental.manager.IncCopyResult; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + public class IncrementalBackupFeedback implements BackupFeedback { private final boolean success; private final IncCopyResult copyResult; + // if the backup failed because of an exception, set this. + // Otherwise, this should be null. + private final Throwable throwable; public IncrementalBackupFeedback(boolean success, @Nullable IncCopyResult copyResult) { this.success = success; this.copyResult = copyResult; + this.throwable = null; + } + + /** + * Create a failed backup feedback caused by an exception. + * + * @param t the exception. + */ + public IncrementalBackupFeedback(Throwable t) { + Objects.requireNonNull(t); + this.success = false; + this.copyResult = null; + this.throwable = t; } @Override @@ -26,6 +44,6 @@ public class IncrementalBackupFeedback implements BackupFeedback { if (success && copyResult != null) return copyResult.toString(); else - return "Backup failed."; + return (throwable == null) ? "No further information." : (throwable.getLocalizedMessage()); } } |