protected void parse(final String resourceId, final Parser parser, InputStream is, final ContentHandler handler, final Metadata m, final ParseContext parseContext)
            throws Throwable {

        try {
            parser.parse(is, handler, m, parseContext);
        } catch (Throwable t) {
            if (t instanceof OutOfMemoryError) {
                LOG.error(getXMLifiedLogMsg(OOM, resourceId, t));
            } else if (t instanceof Error) {
                LOG.error(getXMLifiedLogMsg(PARSE_ERR, resourceId, t));
            } else {
                LOG.warn(getXMLifiedLogMsg(PARSE_EX, resourceId, t));
                incrementHandledExceptions();
            }
            throw t;
        } finally {
            close(is);
        }
    }
Utility method to handle logging equivalently among all
implementing classes.  Use, override or avoid as desired.

@param resourceId   resourceId
@param parser       parser to use
@param is           inputStream (will be closed by this method!)
@param handler      handler for the content
@param m            metadata
@param parseContext parse context
@throws Throwable (logs and then throws whatever was thrown (if anything)
tika-batch/src/main/java/org/apache/tika/batch/FileResourceConsumer.java