From b9664681a376b7cf511a47e72d055b73ae1ac817 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Thu, 19 Nov 2009 15:29:20 -0800 Subject: [PATCH] Better error reporting for narwhal-jsc --- .../CommonJS/lib/objective-j/compiler.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Objective-J/CommonJS/lib/objective-j/compiler.js b/Objective-J/CommonJS/lib/objective-j/compiler.js index cb1e5a5a2..a5c88233e 100644 --- a/Objective-J/CommonJS/lib/objective-j/compiler.js +++ b/Objective-J/CommonJS/lib/objective-j/compiler.js @@ -83,11 +83,11 @@ function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags) for (var index = 0; index < fragments.length; index++) { var fragment = fragments[index]; - + if (IS_FILE(fragment)) preprocessed += (IS_LOCAL(fragment) ? MARKER_IMPORT_LOCAL : MARKER_IMPORT_STD) + ';' + GET_PATH(fragment).length + ';' + GET_PATH(fragment); else - { + { var code = GET_CODE(fragment); if (shouldCheckSyntax) @@ -99,23 +99,25 @@ function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags) catch (e) { var lines = code.split("\n"), - PAD = 3; - - print("Syntax error in "+GET_FILE(fragment).path+ - " on preprocessed line number "+e.lineNumber+"\n"+ - "\t"+lines.slice(Math.max(0, e.lineNumber - 1 - PAD), e.lineNumber+PAD).join("\n\t")); - - throw e; + PAD = 3, + lineNumber = e.lineNumber || e.line, + errorInfo = "Syntax error in "+GET_FILE(fragment).path+ + " on preprocessed line number "+lineNumber+"\n\n"+ + "\t"+lines.slice(Math.max(0, lineNumber - 1 - PAD), lineNumber+PAD).join("\n\t"); + + print(errorInfo); + + throw errorInfo; } } - + if (shouldCompress) { code = compress("function(){" + code + '}', FILE.basename(aFilePath)); - + code = code.substr("function(){".length, code.length - "function(){};\n\n".length); } - + preprocessed += MARKER_CODE + ';' + code.length + ';' + code; } }