You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Vojtěch Stránský (Jira)" <ji...@apache.org> on 2021/08/04 13:48:00 UTC

[jira] [Created] (GROOVY-10190) DefaultErrorStrategy writes errors into std. err. output and this behaviour can not be overridden

Vojtěch Stránský created GROOVY-10190:
-----------------------------------------

             Summary: DefaultErrorStrategy writes errors into std. err. output and this behaviour can not be overridden
                 Key: GROOVY-10190
                 URL: https://issues.apache.org/jira/browse/GROOVY-10190
             Project: Groovy
          Issue Type: Bug
          Components: parser-antlr4
    Affects Versions: 3.0.8
            Reporter: Vojtěch Stránský


*Problem descriptions:*

When an unexpected error is caught by the Groovy parser then the error strategy reports the error message into standard error output.
{code:java}
 System.err.println("unknown recognition error type: " + e.getClass().getName());{code}
But we want to handle this error in our way (not into terminal) but we can do nothing now.
{code:java}

public class DefaultErrorStrategy implements ANTLRErrorStrategy {

    public void reportError(Parser recognizer, RecognitionException e) {
        if (!this.inErrorRecoveryMode(recognizer)) {
            this.beginErrorCondition(recognizer);
            if (e instanceof NoViableAltException) {
                this.reportNoViableAlternative(recognizer, (NoViableAltException)e);
            } else if (e instanceof InputMismatchException) {
                this.reportInputMismatch(recognizer, (InputMismatchException)e);
            } else if (e instanceof FailedPredicateException) {
                this.reportFailedPredicate(recognizer, (FailedPredicateException)e);
            } else {
                System.err.println("unknown recognition error type: " + e.getClass().getName());
                this.notifyErrorListeners(recognizer, e.getMessage(), e);
            }
        }
    }
}{code}
*Expected result:*

Remove writing into standard error output by deletion of this line:
{code:java}
System.err.println("unknown recognition error type: " + e.getClass().getName());
{code}
Or we would like to be able to change strategy or turn it off



--
This message was sent by Atlassian Jira
(v8.3.4#803005)