jirutka/rsql-parser

Need to build my own message from cz.jirutka.rsql.parser.ParseException

guptapavan31 opened this issue · 1 comments

My application is taking RSQLParserException and converting it to our application specific application.

Now the message created from ParseException::initialise is not usable by our application and I wanted to create my own message using its 3 properties. Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal

I am able to use expectedTokenSequencesVal and tokenImageVal, but since cz.jirutka.rsql.parser.Token is not the public class I am unable to use currentTokenVal. Is cz.jirutka.rsql.parser.Token Intentionally not a public class. Is there alternative way to overwrite ParseException::initialise or some way I can create my own message.

Can you catch this exception and try to convert it to your exception with your own message? is it possible?
I mean put that part in a try/catch block and in the catch block, throw your exception, something like this:

try {
	Node rootNode = new RSQLParser().parse(query);
	spec = rootNode.accept(new CustomRsqlVisitor<Product>());
} catch (RSQLParserException ex) {
	throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Dude, yor query is wrong! check it and try again :)");
}

What do think? May it help you? 🤔