public static IOException wrapException(final String path,
      final String methodName, final IOException exception) {

    if (exception instanceof InterruptedIOException
        || exception instanceof PathIOException) {
      return exception;
    } else {
      String msg = String
          .format("Failed with %s while processing file/directory :[%s] in "
                  + "method:[%s]",
              exception.getClass().getName(), path, methodName);
      try {
        return wrapWithMessage(exception, msg);
      } catch (Exception ex) {
        // For subclasses which have no (String) constructor throw IOException
        // with wrapped message

        return new PathIOException(path, exception);
      }
    }
  }
@Test
  public void testWrapException() throws Exception {
    // Test for IOException with valid (String) constructor
    LambdaTestUtils.intercept(EOFException.class,
        "Failed with java.io.EOFException while processing file/directory "
            + ":[/tmp/abc.txt] in method:[testWrapException]", () -> {
          throw IOUtils.wrapException("/tmp/abc.txt", "testWrapException",
              new EOFException("EOFException "));
        });

    // Test for IOException with  no (String) constructor
    PathIOException returnedEx = LambdaTestUtils
        .intercept(PathIOException.class, "Input/output error:",
            () -> {
              throw IOUtils.wrapException("/tmp/abc.txt", "testWrapEx",
                  new CharacterCodingException());
            });
    assertEquals("/tmp/abc.txt", returnedEx.getPath().toString());
  }