package com.cloudera.flume.conf;
import org.antlr.runtime.MismatchedTokenException;
import org.antlr.runtime.NoViableAltException;
import org.antlr.runtime.RecognitionException;
import org.apache.commons.lang.StringEscapeUtils;
import com.google.common.base.Preconditions;
private static final long serialVersionUID = 1L;
RecognitionException re;
Preconditions.checkArgument(re != null);
this.re = re;
}
public RecognitionException
getExn() {
return re;
}
@Override
if (re instanceof NoViableAltException) {
NoViableAltException nvae = (NoViableAltException) re;
String c = StringEscapeUtils.escapeJava("" + (char) nvae.c);
return "Lexer error at char '" + c + "' at line " + nvae.line + " char "
+ nvae.charPositionInLine;
}
if (re instanceof MismatchedTokenException) {
MismatchedTokenException mte = (MismatchedTokenException) re;
String token = (mte.token == null) ? "\"\"" : mte.token.getText();
return "Parser error: unexpected '" + token + "' at position "
+ mte.charPositionInLine + " line " + mte.line + ": '" + mte.input
+ "'";
}
return "Unknown RecognitionException: " + re.getMessage();
}
}