fix error reported for empty HQL string
This commit is contained in:
parent
e0d08a5f26
commit
bc81eb6d19
|
@ -159,10 +159,15 @@ public class StandardHqlTranslator implements HqlTranslator {
|
||||||
}
|
}
|
||||||
if ( e instanceof NoViableAltException ) {
|
if ( e instanceof NoViableAltException ) {
|
||||||
errorText += message.substring( 0, message.indexOf("'") );
|
errorText += message.substring( 0, message.indexOf("'") );
|
||||||
|
if ( hql.isEmpty() ) {
|
||||||
|
errorText += "'*' (empty query string)";
|
||||||
|
}
|
||||||
|
else {
|
||||||
String lineText = hql.lines().collect( toList() ).get( line -1 );
|
String lineText = hql.lines().collect( toList() ).get( line -1 );
|
||||||
String text = lineText.substring( 0, charPositionInLine) + "*" + lineText.substring(charPositionInLine);
|
String text = lineText.substring( 0, charPositionInLine) + "*" + lineText.substring(charPositionInLine);
|
||||||
errorText += "'" + text + "'";
|
errorText += "'" + text + "'";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if ( e instanceof InputMismatchException ) {
|
else if ( e instanceof InputMismatchException ) {
|
||||||
errorText += message.substring( 0, message.length()-1 )
|
errorText += message.substring( 0, message.length()-1 )
|
||||||
.replace(" expecting {", ", expecting one of the following tokens: ");
|
.replace(" expecting {", ", expecting one of the following tokens: ");
|
||||||
|
|
Loading…
Reference in New Issue