JAL-3628 Fixed oddly worded and non-formatted error popups when saving fails
[jalview.git] / src / jalview / io / BackupFiles.java
index 4f86f3d..e943b23 100644 (file)
@@ -152,11 +152,11 @@ public class BackupFiles
       Cache.log
               .error("Could not create temp file to save to (IOException)");
       Cache.log.error(e.getMessage());
-      Cache.log.debug(e.getStackTrace());
+      Cache.log.debug(Cache.getStackTraceString(e));
     } catch (Exception e)
     {
       Cache.log.error("Exception ctreating temp file for saving");
-      Cache.log.debug(e.getStackTrace());
+      Cache.log.debug(Cache.getStackTraceString(e));
     }
     this.setTempFile(temp);
   }
@@ -218,7 +218,7 @@ public class BackupFiles
       Cache.log.error(
               "IOException when getting Canonical Path of temp file '"
                       + this.getTempFile().getName() + "'");
-      Cache.log.debug(e.getStackTrace());
+      Cache.log.debug(Cache.getStackTraceString(e));
     }
     return path;
   }
@@ -276,7 +276,7 @@ public class BackupFiles
       Cache.log.error(
               "Could not get canonical path for file '" + file + "'");
       Cache.log.error(e.getMessage());
-      Cache.log.debug(e.getStackTrace());
+      Cache.log.debug(Cache.getStackTraceString(e));
       return false;
     }
     String filename = file.getName();
@@ -416,7 +416,7 @@ public class BackupFiles
               Cache.log.error(
                       "Error occurred, probably making new temp file for '"
                               + fileToBeDeleted.getName() + "'");
-              Cache.log.error(e.getStackTrace());
+              Cache.log.error(Cache.getStackTraceString(e));
             }
 
             // reset
@@ -431,7 +431,9 @@ public class BackupFiles
           {
             if (previousFile != null)
             {
-              ret = ret && moveFileToFile(backupfile_n, previousFile);
+              // using boolean '&' instead of '&&' as don't want moveFileToFile
+              // attempt to be conditional (short-circuit)
+              ret = ret & moveFileToFile(backupfile_n, previousFile);
             }
           }
 
@@ -549,7 +551,9 @@ public class BackupFiles
                     suffix, digits);
     Cache.log.debug("BACKUPFILES Moving old file [" + file
             + "] to latestBackupFilename [" + latestBackupFilename + "]");
-    ret |= moveFileToFile(file, new File(latestBackupFilename));
+    // using boolean '&' instead of '&&' as don't want moveFileToFile attempt to
+    // be conditional (short-circuit)
+    ret = ret & moveFileToFile(file, new File(latestBackupFilename));
     Cache.log.debug(
             "BACKUPFILES moving " + file + " to " + latestBackupFilename
                     + " was " + (ret ? "" : "NOT ") + "successful");
@@ -772,7 +776,6 @@ public class BackupFiles
     boolean okay = roll && rename;
     if (!okay)
     {
-      boolean yesno = false;
       StringBuilder messageSB = new StringBuilder();
       messageSB.append(MessageManager.getString(
               "label.backupfiles_confirm_save_file_backupfiles_roll_wrong"));
@@ -797,6 +800,12 @@ public class BackupFiles
                 "label.backupfiles_confirm_save_new_saved_file_not_ok"));
         // "The new saved file might not be okay."
       }
+      if (messageSB.length() > 0)
+      {
+        messageSB.append("\n");
+      }
+      messageSB
+              .append(MessageManager.getString("label.continue_operation"));
 
       int confirmButton = Platform.isHeadless() ? JvOptionPane.OK_OPTION
               : JvOptionPane.showConfirmDialog(Desktop.desktop,
@@ -904,12 +913,12 @@ public class BackupFiles
       Cache.log.warn("Could not move file '" + oldPath.toString() + "' to '"
               + newPath.toString() + "'");
       Cache.log.error(e.getMessage());
-      Cache.log.debug(e.getStackTrace());
+      Cache.log.debug(Cache.getStackTraceString(e));
       ret = false;
     } catch (Exception e)
     {
       Cache.log.error(e.getMessage());
-      Cache.log.debug(e.getStackTrace());
+      Cache.log.debug(Cache.getStackTraceString(e));
       ret = false;
     }
     return ret;