Skip to content

Commit e32eafe

Browse files
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.
1 parent 0ea5509 commit e32eafe

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/src/processing/app/Sketch.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public Sketch(Editor editor, String path) throws IOException {
151151
* Another exception is when an external editor is in use,
152152
* in which case the load happens each time "run" is hit.
153153
*/
154-
protected void load() {
154+
protected void load() throws IOException {
155155
codeFolder = new File(folder, "code");
156156
dataFolder = new File(folder, "data");
157157

@@ -193,6 +193,10 @@ protected void load() {
193193
}
194194
}
195195
}
196+
197+
if (codeCount == 0)
198+
throw new IOException(_("No valid code files found"));
199+
196200
// Remove any code that wasn't proper
197201
code = (SketchCode[]) PApplet.subset(code, 0, codeCount);
198202

@@ -1258,7 +1262,7 @@ public static void buildSettingChanged() {
12581262
* When running from the editor, take care of preparations before running
12591263
* the build.
12601264
*/
1261-
public void prepare() {
1265+
public void prepare() throws IOException {
12621266
// make sure the user didn't hide the sketch folder
12631267
ensureExistence();
12641268

0 commit comments

Comments
 (0)