From e32eafe48f151c05243389c52ccce17a369be342 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 25 Oct 2013 15:01:29 +0200 Subject: [PATCH] Handle sketch with only invalid code filenames Previously, this would error out with an index out of bounds exception. Now, an IOException is thrown, which is properly handled further up the call chain. --- app/src/processing/app/Sketch.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 3f38f80ca..33f4111ef 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -151,7 +151,7 @@ public class Sketch { * Another exception is when an external editor is in use, * in which case the load happens each time "run" is hit. */ - protected void load() { + protected void load() throws IOException { codeFolder = new File(folder, "code"); dataFolder = new File(folder, "data"); @@ -193,6 +193,10 @@ public class Sketch { } } } + + if (codeCount == 0) + throw new IOException(_("No valid code files found")); + // Remove any code that wasn't proper code = (SketchCode[]) PApplet.subset(code, 0, codeCount); @@ -1258,7 +1262,7 @@ public class Sketch { * When running from the editor, take care of preparations before running * the build. */ - public void prepare() { + public void prepare() throws IOException { // make sure the user didn't hide the sketch folder ensureExistence();