public void handleLoss(String loss) {
        lossHandler.accept(new UnwritableMetadataException(requestedMetadataVersion, loss));
    }
@Test
    public void testHandleLoss() {
        String expectedMessage = "stuff";

        for (int i = MetadataVersion.MINIMUM_KRAFT_VERSION.ordinal();
             i < MetadataVersion.VERSIONS.length;
             i++) {
            MetadataVersion version = MetadataVersion.VERSIONS[i];
            String formattedMessage = String.format("Metadata has been lost because the following could not be represented in metadata.version %s: %s", version, expectedMessage);
            Consumer<UnwritableMetadataException> customLossHandler = e -> assertEquals(formattedMessage, e.getMessage());
            ImageWriterOptions options = new ImageWriterOptions.Builder()
                    .setMetadataVersion(version)
                    .setLossHandler(customLossHandler)
                    .build();
            options.handleLoss(expectedMessage);
        }
    }