From 3589e79fe846084e9228a54f2f88dabc3a541122 Mon Sep 17 00:00:00 2001 From: Laurence Trippen <32238327+laurence-trippen@users.noreply.github.com> Date: Sat, 21 Oct 2017 00:35:07 +0200 Subject: [PATCH] added exception handling --- README.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7f4bb01..ea2274b 100644 --- a/README.md +++ b/README.md @@ -95,20 +95,33 @@ of the ConfigManager. ;-) ## The Test class ```java import com.laurencetrippen.jpg.ConfigManager; +import com.laurencetrippen.jpg.exception.ConfigFileAlreadyExistException; +import com.laurencetrippen.jpg.exception.ConfigFileNotDefinedException; +import com.laurencetrippen.jpg.exception.ConfigFileNotExistException; +import com.laurencetrippen.jpg.exception.PathNotExistException; public class Tester { - public static void main(String[] args) { + public static void main(String[] args) throws ConfigFileNotDefinedException, PathNotExistException { ConfigManager cm = new ConfigManager<>(Configuration.class); - cm.generateConfig(); - Configuration cfg = cm.load(); + try { + cm.generateConfig(); + } catch (ConfigFileAlreadyExistException e) { + e.printStackTrace(); + } - cfg.setPort(880); - cfg.setIp("255.255.255.255"); - cfg.setTimeout(20.2f); - cfg.setDelay(20.4054); - cfg.setLazyLoading(true); + Configuration cfg = null; + try { + cfg = cm.load(); + cfg.setPort(880); + cfg.setIp("255.255.255.255"); + cfg.setTimeout(20.2f); + cfg.setDelay(20.4054); + cfg.setLazyLoading(true); + } catch (ConfigFileNotExistException e) { + e.printStackTrace(); + } cm.save(cfg); }