private void doError(String message, Token tok) {
    hadError = true;
    if (eh != null) {
      LocatorImpl loc = new LocatorImpl();
      loc.setLineNumber(tok.beginLine);
      loc.setColumnNumber(tok.beginColumn);
      loc.setSystemId(sourceUri);
      try {
        eh.error(new SAXParseException(message, loc));
      }
      catch (SAXException se) {
        throw new BuildException(se);
      }
    }
  }