Error handle filetree generation

This commit is contained in:
Oystein Kristoffer Tveit 2021-04-22 22:02:23 +02:00
parent 581bb0ad3b
commit 505f6872f2
2 changed files with 12 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import app.events.OpenFileEvent;
import app.events.OpenProjectEvent;
import app.events.SaveFileEvent;
import app.model.Model;
import app.service.DialogBoxes;
import app.service.FiletreeOperations;
import javafx.fxml.Initializable;
@ -56,9 +57,17 @@ public class FiletreeController implements Initializable, Controller {
filetree.setShowRoot(false);
File fileInputChosen = new File(inputChosen);
try {
FiletreeOperations.generateTree(fileInputChosen, root);
filetree.setRoot(root);
} catch (Exception e) {
Model.setProjectPath(Optional.empty());
DialogBoxes.showErrorMessage(
"Could not open folder.\n\n"
+ "Do you have the right permissions for this folder?\n"
+ "Or does the folder contain any shortcut to somewhere within itself?");
}
}
/* ------------------------------------------------------------------------ */

View File

@ -51,8 +51,7 @@ public class FileOperations {
return true;
} catch (FileNotFoundException ex) {
DialogBoxes.showErrorMessage("Could not save file!");
System.err.println(filepath);
DialogBoxes.showErrorMessage("Could not save file at \n" + filepath.toString());
return false;
}
}