From 510385ccd37c71c3810e47b6461d27199174efad Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Sun, 27 Mar 2016 08:18:32 -0700 Subject: [PATCH] Better error reporting. --- .../src/org/demo/PackPartitions.groovy | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy index 5e1c340b..729d281b 100644 --- a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy +++ b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy @@ -921,7 +921,7 @@ class PackPartitions mapEl.scripts ? mapEl.scripts[0] : [], totalWidth, totalHeight, xRange, yRange) replaceIfDiff(scriptDir + name + ".pla") - compileModule(name, scriptDir, false) // false=not verbose + compileModule(name, "src/mapScripts/", false) // false=not verbose return [num, module.locationsWithTriggers] } @@ -1291,8 +1291,10 @@ class PackPartitions { def prevStdin = System.in def prevStdout = System.out + def prevStderr = System.err def prevUserDir = System.getProperty("user.dir") def result + def errBuf = new ByteArrayOutputStream() try { System.setProperty("user.dir", new File(inDir).getAbsolutePath()) @@ -1301,6 +1303,7 @@ class PackPartitions System.in = inStream outFile.withOutputStream { outStream -> System.out = new PrintStream(outStream) + System.err = new PrintStream(errBuf) result = programClass.newInstance().run(args) } } @@ -1311,10 +1314,15 @@ class PackPartitions } finally { System.in = prevStdin System.out = prevStdout + System.err = prevStderr System.setProperty("user.dir", prevUserDir) } - if (result != 0) - throw new Exception("$programName failed with code $result") + if (result != 0) { + def errStr = errBuf.toString("UTF-8") + if (errStr.length() > 0) + errStr = "\nError output:\n" + errStr + "-----\n" + throw new Exception("$programName (cd $inDir && ${args.join(' ')}) < $inFile > $outFile failed with code $result." + errStr) + } } /**