Skip to content

Navigation Menu

Sign in
Sign up

Expected error is raised only after second (identical) attempt #98

Open

Description

The following code throws only after second call to parse, instead of throwing upon first call as expected.

private static final class ThrowingErrorHandler implements ErrorHandler {
 @Override
 public void warning(SAXParseException exception) throws SAXParseException {
 LOGGER.info("Warning while processing.", exception);
 throw exception;
 }
 @Override
 public void fatalError(SAXParseException exception) throws SAXParseException {
 LOGGER.info("Fatal while processing.", exception);
 throw exception;
 }
 @Override
 public void error(SAXParseException exception) throws SAXParseException {
 LOGGER.info("Error while processing.", exception);
 throw exception;
 }
}
@Test
public void testHtmlIso() throws Exception {
 String uri = "https://github.com/oliviercailloux/JARiS/raw/refs/heads/main/src/test/resources/io/github/oliviercailloux/jaris/xml/Html/Encoding%20ISO.html";
 HtmlDocumentBuilder builder = new HtmlDocumentBuilder();
 builder.setErrorHandler(new ThrowingErrorHandler());
 // logs no warning, does not throw
 builder.parse(uri);
 builder.setErrorHandler(new ThrowingErrorHandler());
 // logs a warning then throws
 builder.parse(uri);
}

Explanation

The document is supposed to raise a warning when parsed, and given the registered ThrowingErrorHandler, it is supposed to log then throw an exception when parsing. But the first parse completes without logging or throwing anything. Only the second one does.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /