1 18 package org.codehaus.groovy.antlr; 19 20 import antlr.collections.AST; 21 22 26 public class ASTRuntimeException extends RuntimeException { 27 private AST ast; 28 29 public ASTRuntimeException(AST ast, String message) { 30 super(message + description(ast)); 31 this.ast = ast; 32 } 33 34 public ASTRuntimeException(AST ast, String message, Throwable throwable) { 35 super(message + description(ast), throwable); 36 } 37 38 protected static String description(AST node) { 39 return (node != null) ? " at line: " + node.getLine() + " column: " + node.getColumn() : ""; 40 } 41 42 public AST getAst() { 43 return ast; 44 } 45 46 public int getLine() { 47 return ast != null ? ast.getLine() : -1; 48 } 49 50 public int getColumn() { 51 return ast != null ? ast.getColumn() : -1; 52 } 53 54 } 55 | Popular Tags |