return new CompilerResult(compileCode(code, bare));
} catch (StoppedContextException e) {
return null; // Canceled
} catch (JavaScriptException e) {
if (e.getValue() instanceof IdScriptableObject) {
IdScriptableObject error = (IdScriptableObject) e.getValue();
String message = (String) ScriptableObject.getProperty(error, "message");
IdScriptableObject location = (IdScriptableObject) ScriptableObject.getProperty(error, "location");
Double line = (Double) ScriptableObject.getProperty(location, "first_line");
Double column = (Double) ScriptableObject.getProperty(location, "first_column");
return new CompilerResult(new Error(line == null ? -1 : line.intValue()+1, column == null ? 0 : column.intValue()+1, message, message));
}
return new CompilerResult(new Error(-1, "", e.getMessage()));