private String getParserErrorMessage ( ) { StringBuffer code = new StringBuffer ( text ) ; code = code . insert ( maxPosition , " >><< " ) ; String codeString = code . substring ( maxPosition - 100 < 0 ? 0 : maxPosition - 100 , maxPosition + 100 >= code . length ( ) ? code . length ( ) : maxPosition + 100 ) ; return "Could not parse the input string near '" + codeString + "'!" ; }
This message just generates a parser exception message to be returned containing the maximum position where the parser could not proceed . This should be in most cases the position where the error within the text is located .