Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10190

DefaultErrorStrategy writes errors into std. err. output and this behaviour can not be overridden

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0.8
    • None
    • parser-antlr4
    • None

    Description

      Problem descriptions:

      When an unexpected error is caught by the Groovy parser then the error strategy reports the error message into standard error output.

       System.err.println("unknown recognition error type: " + e.getClass().getName());

      But we want to handle this error in our way (not into terminal) but we can do nothing now.

      
      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);
                  }
              }
          }
      }

      Expected result:

      Remove writing into standard error output by deletion of this line:

      System.err.println("unknown recognition error type: " + e.getClass().getName());
      

      Or we would like to be able to change strategy or turn it off

      Attachments

        Activity

          People

            Unassigned Unassigned
            Straaka Vojtěch Stránský
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: