Exception handling improvements to SettingsLoader

This commit is contained in:
Rohit Awate 2018-09-01 10:58:18 +05:30
parent 4701fc18ff
commit d5b4c36fae
2 changed files with 13 additions and 2 deletions

View file

@ -92,6 +92,11 @@ public class AuthTabController implements Initializable {
basicController.setState(state.basicUsername, state.basicPassword, state.basicEnabled);
digestController.setState(state.digestUsername, state.digestPassword, state.digestEnabled);
if (state.authMethod == null) {
authTabPane.getSelectionModel().select(0);
return;
}
switch (state.authMethod) {
case DataManager.BASIC:
authTabPane.getSelectionModel().select(0);

View file

@ -42,7 +42,11 @@ public class SettingsLoader implements Runnable {
File settingsFile = new File("Everest/config/settings.json");
if (settingsFile.exists())
System.out.println("Settings file found. Loading settings... ");
LoggingService.logInfo("Settings file found. Loading settings.", LocalDateTime.now());
else {
LoggingService.logInfo("Settings file not found. Loading defaults.", LocalDateTime.now());
return;
}
nodes = EverestUtilities.jsonMapper.readTree(settingsFile);
@ -60,7 +64,9 @@ public class SettingsLoader implements Runnable {
Settings.syntaxTheme = EverestUtilities.trimString(setStringSetting(Settings.syntaxTheme, "syntaxTheme"));
Settings.showHistoryRange = setIntegerSetting(Settings.showHistoryRange, "showHistoryRange");
} catch (IOException IOE) {
LoggingService.logInfo("Settings file not found. Using defaults.", LocalDateTime.now());
LoggingService.logInfo("Settings file contains invalid JSON. Loading defaults.", LocalDateTime.now());
} catch (NullPointerException NPE) {
LoggingService.logInfo("Settings file empty. Loading defualts", LocalDateTime.now());
}
}