summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java2
-rw-r--r--src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/IncrementalBackupFeedback.java20
-rw-r--r--src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java4
3 files changed, 22 insertions, 4 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
index 0d9cb65..1798fb7 100644
--- a/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
+++ b/src/main/java/com/keuin/kbackupfabric/operation/BackupOperation.java
@@ -56,7 +56,7 @@ public class BackupOperation extends InvokableAsyncBlockingOperation {
PrintUtil.msgInfo(context, msgText, true);
} else {
// failed
- PrintUtil.msgErr(context, "Backup operation failed. No further information.");
+ PrintUtil.msgErr(context, "Backup operation failed: " + result.getFeedback());
}
} catch (SecurityException e) {
msgInfo(context, String.format("Failed to create backup saving directory: %s. Failed to backup.", backupSaveDirectory));
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());
}
}
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java b/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java
index 0c202e1..2cc0765 100644
--- a/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java
+++ b/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java
@@ -99,8 +99,8 @@ public class ConfiguredIncrementalBackupMethod implements ConfiguredBackupMethod
PrintUtil.info("Incremental backup finished.");
feedback = new IncrementalBackupFeedback(true, copyResult);
} catch (IOException e) {
- e.printStackTrace(); // at least we should print it out if we discard the exception... Better than doing nothing.
- feedback = new IncrementalBackupFeedback(false, null);
+// e.printStackTrace(); // stack trace has been passed to backup feedback. No need to print here.
+ feedback = new IncrementalBackupFeedback(e);
}
// do clean-up if failed