From a5ddb2994db775f29a19d0e503f67bb02cba6f6b Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 29 Oct 2021 23:13:43 +0200 Subject: [PATCH] Catch failures on loading LUA files --- .../de/c3ma/ollo/mockup/DoFileFunction.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/simulation/src/de/c3ma/ollo/mockup/DoFileFunction.java b/simulation/src/de/c3ma/ollo/mockup/DoFileFunction.java index 0d3d741..c88d3ed 100644 --- a/simulation/src/de/c3ma/ollo/mockup/DoFileFunction.java +++ b/simulation/src/de/c3ma/ollo/mockup/DoFileFunction.java @@ -27,13 +27,18 @@ public class DoFileFunction extends OneArgFunction { String filename = luaFilename.checkjstring(); File f = new File(workingDir.getAbsolutePath() + File.separator + filename); - - if (f.exists()) { - LuaValue chunk = this.globals.loadfile(f.getAbsolutePath()); - chunk.call(); - return LuaValue.valueOf(true); - } else { - return LuaValue.valueOf(false); + try { + if (f.exists()) { + LuaValue chunk = this.globals.loadfile(f.getAbsolutePath()); + chunk.call(); + return LuaValue.valueOf(true); + } else { + return LuaValue.valueOf(false); + } + } catch (Exception e) { + System.err.println("Cannot load " + f.getName()); + e.printStackTrace(); + return LuaValue.valueOf(false); } }