code: public SyntaxException getSyntaxError(int index) {
          SyntaxException exception = null;
  
          Message message = getError(index);
          if (message != null && message instanceof SyntaxErrorMessage) {
              exception = ((SyntaxErrorMessage) message).getCause();
          }
          return exception;
      }
docs: Convenience routine to return the specified error's
  underlying SyntaxException, or null if it isn't one.