adjust error handling to catch all errors when reading config

This commit is contained in:
Draylar
2021-04-03 17:23:36 -05:00
parent 8b42f5a9c5
commit 1e3e886346
2 changed files with 9 additions and 5 deletions
@@ -85,9 +85,10 @@ public class OmegaConfig {
writeConfig(configClass, object); writeConfig(configClass, object);
REGISTERED_CONFIGURATIONS.add(object); REGISTERED_CONFIGURATIONS.add(object);
return object; return object;
} catch (IOException ioException) { } catch (Exception e) {
LOGGER.error(ioException); LOGGER.error(e);
LOGGER.info(String.format("Read error, using default values for config %s.", configClass.toString())); LOGGER.info(String.format("Encountered an error while reading %s config, falling back to default values.", config.getName()));
LOGGER.info(String.format("If this problem persists, delete the config file %s and try again.", config.getName() + "." + config.getExtension()));
} }
} }
@@ -2,11 +2,14 @@ package draylar.omegatest.config;
import draylar.omegaconfig.api.Config; import draylar.omegaconfig.api.Config;
import java.util.Arrays;
import java.util.List;
public class ClassConfigTest implements Config { public class ClassConfigTest implements Config {
public TestClass[] testClass = { public List<TestClass> l = Arrays.asList(
new TestClass() new TestClass()
}; );
@Override @Override
public String getName() { public String getName() {