improve invalid document reporting (add InvalidDocumentException)