Mercurial Hosting > luan
diff lucene/src/luan/modules/lucene/queryparser/ParseException.java @ 730:01e68da6983b
add sane-lucene-queryparser source to luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 10 Jun 2016 15:41:15 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lucene/src/luan/modules/lucene/queryparser/ParseException.java Fri Jun 10 15:41:15 2016 -0600 @@ -0,0 +1,33 @@ +package luan.modules.lucene.queryparser; + + +public final class ParseException extends Exception { + public final String text; + public final int errorIndex; + public final int highIndex; + + public ParseException(SaneQueryParser qp) { + this(qp,"Invalid input"); + } + + public ParseException(SaneQueryParser qp,String msg) { + super(msg+" at position "+(qp.parser.errorIndex()+1)); + Parser parser = qp.parser; + this.text = parser.text; + this.errorIndex = parser.errorIndex(); + this.highIndex = parser.highIndex(); + } + + public ParseException(SaneQueryParser qp,Exception cause) { + this(qp,cause.getMessage(),cause); + } + + public ParseException(SaneQueryParser qp,String msg,Exception cause) { + super(msg+" at position "+(qp.parser.errorIndex()+1),cause); + Parser parser = qp.parser; + this.text = parser.text; + this.errorIndex = parser.errorIndex(); + this.highIndex = parser.highIndex(); + } + +}