01: package org.codehaus.groovy.syntax;
02:
03: import groovy.lang.GroovyRuntimeException;
04:
05: import org.codehaus.groovy.ast.ASTNode;
06: import org.codehaus.groovy.syntax.SyntaxException;
07:
08: /**
09: * A helper class to allow parser exceptions to be thrown anywhere in the code.
10: * Should be replaced when no longer required.
11: *
12: * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
13: * @version $Revision: 2120 $
14: */
15: public class RuntimeParserException extends GroovyRuntimeException {
16:
17: public RuntimeParserException(String message, ASTNode node) {
18: super (message + ".\nNode: " + node.getClass().getName(), node);
19: }
20:
21: public void throwParserException() throws SyntaxException {
22: throw new SyntaxException(getMessage(), getNode()
23: .getLineNumber(), getNode().getColumnNumber());
24: }
25:
26: /*
27: private Token token;
28:
29: public RuntimeParserException(String message, Token token) {
30: super(message);
31: this.token = token;
32: }
33:
34: public Token getToken() {
35: return token;
36: }
37:
38: public void throwParserException() throws SyntaxException {
39: throw new TokenException(getMessage(), token);
40: }
41: */
42: }
|