From 226a41abbfb3ad69f8cb91ce017aaf6b2c1e3f0f Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 28 Oct 2009 12:05:43 +0000 Subject: [PATCH] throw exception if project directory or config file does not exist --- .../java/se/sics/cooja/ProjectConfig.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/ProjectConfig.java b/tools/cooja/java/se/sics/cooja/ProjectConfig.java index cd7834838..e60f488f9 100644 --- a/tools/cooja/java/se/sics/cooja/ProjectConfig.java +++ b/tools/cooja/java/se/sics/cooja/ProjectConfig.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ProjectConfig.java,v 1.3 2008/10/03 10:23:33 fros4943 Exp $ + * $Id: ProjectConfig.java,v 1.4 2009/10/28 12:05:43 fros4943 Exp $ */ package se.sics.cooja; @@ -135,15 +135,19 @@ public class ProjectConfig { */ public boolean appendProjectDir(File projectDir) throws FileNotFoundException, IOException { - myProjectDirHistory.add(projectDir); - - File projectConfig = new File(projectDir.getPath(), - GUI.PROJECT_CONFIG_FILENAME); - if (projectConfig.exists()) { - return appendConfigFile(projectConfig); + if (projectDir == null) { + throw new FileNotFoundException("No project directory specified"); } - - return true; + if (!projectDir.exists()) { + throw new FileNotFoundException("Project directory does not exist: " + projectDir.getAbsolutePath()); + } + + File projectConfig = new File(projectDir.getPath(), GUI.PROJECT_CONFIG_FILENAME); + if (!projectConfig.exists()) { + throw new FileNotFoundException("Project config does not exist: " + projectConfig.getAbsolutePath()); + } + myProjectDirHistory.add(projectDir); + return appendConfigFile(projectConfig); }