private static void throwDeleteFailed ( Path path , Collection < IOException > exceptions ) throws FileSystemException { // TODO(cgdecker): Should there be a custom exception type for this? // Also, should we try to include the Path of each file we may have failed to delete rather // than just the exceptions that occurred? FileSystemException deleteFailed = new FileSystemException ( path . toString ( ) , null , "failed to delete one or more files; see suppressed exceptions for details" ) ; for ( IOException e : exceptions ) { deleteFailed . addSuppressed ( e ) ; } throw deleteFailed ; }
Throws an exception indicating that one or more files couldn t be deleted . The thrown exception contains all the exceptions in the given collection as suppressed exceptions .