Add setting reinitialization if loading fails
This commit is contained in:
parent
392d10c587
commit
b6a6ec5e3a
@ -185,17 +185,23 @@ public class MainController implements Initializable {
|
|||||||
|
|
||||||
Result<MainSettings, Exception> result = MainSettings.load();
|
Result<MainSettings, Exception> result = MainSettings.load();
|
||||||
if (!result.hasSuccess()) {
|
if (!result.hasSuccess()) {
|
||||||
// TODO: on failure, prompt user to re-initialize settings
|
Alert alert = new Alert(Alert.AlertType.ERROR, "Unable to load settings file. See log for details. Reinitialize settings? This may overwrite existing settings.", ButtonType.YES, ButtonType.NO);
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
||||||
alert.setTitle("Settings load error");
|
alert.setTitle("Settings load error");
|
||||||
alert.setHeaderText(null);
|
alert.setHeaderText(null);
|
||||||
alert.setContentText("Unable to load settings file");
|
Optional<ButtonType> promptResult = alert.showAndWait();
|
||||||
alert.showAndWait();
|
|
||||||
|
|
||||||
return;
|
if (!promptResult.isPresent()) {
|
||||||
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (promptResult.get() == ButtonType.NO) {
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
settings = new MainSettings();
|
||||||
|
} else {
|
||||||
settings = result.getSuccess().get();
|
settings = result.getSuccess().get();
|
||||||
|
}
|
||||||
|
|
||||||
selectedStationName.set(settings.getSelectedStationName());
|
selectedStationName.set(settings.getSelectedStationName());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user