public static void deleteIfExists(final File file)
    {
        try
        {
            Files.deleteIfExists(file.toPath());
        }
        catch (final IOException ex)
        {
            LangUtil.rethrowUnchecked(ex);
        }
    }
@Test
    void deleteIfExistsErrorHandlerFailsOnNonEmptyDirectory() throws IOException
    {
        final ErrorHandler errorHandler = mock(ErrorHandler.class);
        final Path dir = tempDir.resolve("dir");
        Files.createDirectory(dir);
        Files.createFile(dir.resolve("file.txt"));

        IoUtil.deleteIfExists(dir.toFile(), errorHandler);

        verify(errorHandler).onError(isA(DirectoryNotEmptyException.class));
    }