Java Code Examples for java.nio.file.FileSystemException#initCause()

The following examples show how to use java.nio.file.FileSystemException#initCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultFileSystemExceptionFactory.java    From sftp-fs with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * If the {@link SftpException#id id} of the {@link SftpException} is not {@link ChannelSftp#SSH_FX_NO_SUCH_FILE} or
 * {@link ChannelSftp#SSH_FX_PERMISSION_DENIED}, this default implementation does not return a {@link FileSystemException}, but a
 * {@link NotLinkException} instead.
 */
@Override
public FileSystemException createReadLinkException(String link, SftpException exception) {
    if (exception.id == ChannelSftp.SSH_FX_NO_SUCH_FILE || exception.id == ChannelSftp.SSH_FX_PERMISSION_DENIED) {
        return asFileSystemException(link, null, exception);
    }
    final FileSystemException result = new NotLinkException(link, null, exception.getMessage());
    result.initCause(exception);
    return result;
}
 
Example 2
Source File: SFTPEnvironment.java    From sftp-fs with Apache License 2.0 5 votes vote down vote up
FileSystemException asFileSystemException(Exception e) throws FileSystemException {
    if (e instanceof FileSystemException) {
        throw (FileSystemException) e;
    }
    FileSystemException exception = new FileSystemException(null, null, e.getMessage());
    exception.initCause(e);
    throw exception;
}
 
Example 3
Source File: SSHChannelPool.java    From sftp-fs with Apache License 2.0 5 votes vote down vote up
IOException asIOException(Exception e) throws IOException {
    if (e instanceof IOException) {
        throw (IOException) e;
    }
    FileSystemException exception = new FileSystemException(null, null, e.getMessage());
    exception.initCause(e);
    throw exception;
}
 
Example 4
Source File: WatchmanBuildPackageComputation.java    From buck with Apache License 2.0 5 votes vote down vote up
private FileSystemException enrichFileSystemException(FileSystemException exception) {
  if (!(exception instanceof NotDirectoryException) && isNotADirectoryError(exception)) {
    FileSystemException e = new NotDirectoryException(exception.getFile());
    e.initCause(exception);
    return e;
  }
  return exception;
}