001    package org.codehaus.groovy.syntax;
002    
003    import groovy.lang.GroovyRuntimeException;
004    
005    import org.codehaus.groovy.ast.ASTNode;
006    import org.codehaus.groovy.syntax.SyntaxException;
007    
008    /** 
009     * A helper class to allow parser exceptions to be thrown anywhere in the code. 
010     * Should be replaced when no longer required.
011     * 
012     * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
013     * @version $Revision: 2120 $
014     */ 
015    public class RuntimeParserException extends GroovyRuntimeException {
016        
017        public RuntimeParserException(String message, ASTNode node) {
018            super(message + ".\nNode: " + node.getClass().getName(), node);
019        }
020    
021        public void throwParserException() throws SyntaxException {
022            throw new SyntaxException(getMessage(), getNode().getLineNumber(), getNode().getColumnNumber());
023        }
024        
025        /*
026        private Token token;
027    
028        public RuntimeParserException(String message, Token token) {
029            super(message);
030            this.token = token;
031        }
032    
033        public Token getToken() {
034            return token;
035        }
036    
037        public void throwParserException() throws SyntaxException {
038            throw new TokenException(getMessage(), token);
039        }
040        */
041    }