/** * Constructor. * * @param name * the name of template. * @param compileException * the {@link CompileException}. * @param columnNumber * the column where the expression starts. * @param lineNumber * the line where the expression starts. */ public NamedCompileException(final String name, final CompileException compileException, final int columnNumber, final int lineNumber) { super("", compileException.getExpr(), compileException.getCursor()); compileException.setColumn(columnNumber); compileException.setLineNumber(lineNumber); compileException.setErrors(compileException.getErrors()); // setEvaluationContext(); compileException.setLastLineStart(compileException.getLastLineStart()); compileException.setStackTrace(compileException.getStackTrace()); wrappedCompileException = compileException; this.name = name; }
@Override public Object eval(final Map<String, Object> vars) { try { return MVEL.executeExpression(mvelExpression, vars); } catch (CompileException e) { e.getMessage(); if (e.getLineNumber() == 1) { e.setColumn((e.getColumn() + column) - 1); } e.setLineNumber((e.getLineNumber() + lineNumber) - 1); throw e; } catch (NoClassDefFoundError e) { PropertyAccessException pe = new PropertyAccessException( "Type of variable or property could not be resolved during evaluating expression.", expression.toCharArray(), 0, e, null); pe.setColumn(column); pe.setLineNumber(lineNumber); throw pe; } }
public static CompileException rewriteIfNeeded(CompileException caught, char[] outer, int outerCursor) { if (outer != caught.getExpr()) { if (caught.getExpr().length <= caught.getCursor()) { caught.setCursor(caught.getExpr().length - 1); } try { String innerExpr = new String(caught.getExpr()).substring(caught.getCursor()); caught.setExpr(outer); String outerStr = new String(outer); int newCursor = outerStr.substring(outerStr.indexOf(new String(caught.getExpr()))) .indexOf(innerExpr); caught.setCursor(newCursor); } catch (Throwable t) { t.printStackTrace(); } } return caught; }
public static void copyErrorLocation(Exception e, BaseDescr descr) { if (e instanceof CompileException) { CompileException compileException = (CompileException)e; compileException.setLineNumber(descr.getLine()); compileException.setColumn(descr.getColumn()); } }
CompileException ce = new CompileException(e.getMessage(), template, cursor, e); ce.setExpr(template); if (ce2.getCursor() != -1) { ce.setCursor(ce2.getCursor()); if (ce2.getColumn() == -1) ce.setColumn(ce.getCursor() - colStart); else ce.setColumn(ce2.getColumn()); ce.setLineNumber(line); CompileException ce = new CompileException("unclosed @" + ((Node) stack.peek()).getName() + "{} block. expected @end{}", template, cursor); ce.setColumn(cursor - colStart); ce.setLineNumber(line); throw ce;
if (!tk.isOperator()) { if (!(stk.peek() instanceof Class)) { throw new CompileException("unexpected token: " + tk.getName()); e.setExpr(expr); e.setLineNumber(line + e.getLineNumber()); e.setCursor(cursor); throw e; CompileException ce = new CompileException("incomplete statement: " + tk.getName() + " (possible use of reserved keyword as identifier: " + tk.getName() + ")", e); ce.setExpr(expr); ce.setLineNumber(line); ce.setCursor(cursor); throw ce;
public void checkArgumentCount(int passing) { if (passing != parmNum) { throw new CompileException("bad number of arguments in function call: " + passing + " (expected: " + (parmNum == 0 ? "none" : parmNum) + ")", expr, start); } }
throw new CompileException("unterminated '['", this.expr, this.start); throw new CompileException("unterminated '['", this.expr, this.start); e.setExpr(this.expr); e.setCursor(start); throw e; throw new CompileException("illegal use of []: unknown type: " + ctx.getClass().getName(), this.expr, this.start);
e.getMessage(); int columnNumber = e.getColumn(); if (e.getLineNumber() == 1) { columnNumber = (e.getColumn() + parserConfiguration.getStartColumn()) - 1; int lineNumber = (e.getLineNumber() + parserConfiguration.getStartRow()) - 1; throw new NamedCompileException(parserConfiguration.getName(), e, columnNumber, lineNumber);
@Override public void setColumn(final int column) { wrappedCompileException.setColumn(column); }
@Override public void setLineNumber(final int lineNumber) { wrappedCompileException.setLineNumber(lineNumber); }
@Override public String getMessage() { return generateErrorMessage(); }
@Override public int getCursor() { return wrappedCompileException.getCursor(); }
@Override public void setExpr(final char[] expr) { wrappedCompileException.setExpr(expr); }
@Override public int getColumn() { return wrappedCompileException.getColumn(); }
@Override public void setCursor(final int cursor) { wrappedCompileException.setCursor(cursor); }
@Override public List<ErrorDetail> getErrors() { return wrappedCompileException.getErrors(); }
@Override public char[] getExpr() { return wrappedCompileException.getExpr(); }
CompileException ce = new CompileException(e.getMessage(), template, cursor, e); ce.setExpr(template); if (ce2.getCursor() != -1) { ce.setCursor(ce2.getCursor()); if (ce2.getColumn() == -1) ce.setColumn(ce.getCursor() - colStart); else ce.setColumn(ce2.getColumn()); ce.setLineNumber(line); CompileException ce = new CompileException("unclosed @" + ((Node) stack.peek()).getName() + "{} block. expected @end{}", template, cursor); ce.setColumn(cursor - colStart); ce.setLineNumber(line); throw ce;
if (!tk.isOperator()) { if (!(stk.peek() instanceof Class)) { throw new CompileException("unexpected token or unknown identifier:" + tk.getName(), expr, st); CompileException ce = new CompileException("incomplete statement: " + tk.getName() + " (possible use of reserved keyword as identifier: " + tk.getName() + ")" , expr, st, e); ce.setExpr(expr); ce.setLineNumber(line); ce.setCursor(cursor); throw ce;