Search in sources :

Example 6 with NoSuchFileSftpException

use of com.jn.agileway.ssh.client.sftp.exception.NoSuchFileSftpException in project agileway by fangjinuo.

the class Ssh2Sftps method wrapSftpException.

public static SftpException wrapSftpException(Throwable ex) {
    if (ex instanceof SFTPException) {
        ResponseStatusCode statusCode = Enums.ofCode(ResponseStatusCode.class, ((SFTPException) ex).getServerErrorCode());
        SftpException exception = null;
        if (statusCode == ResponseStatusCode.NO_SUCH_FILE) {
            exception = new NoSuchFileSftpException(ex);
        } else {
            exception = new SftpException(ex);
        }
        exception.setStatusCode(statusCode);
        return exception;
    } else {
        return new SftpException(ex);
    }
}
Also used : NoSuchFileSftpException(com.jn.agileway.ssh.client.sftp.exception.NoSuchFileSftpException) ResponseStatusCode(com.jn.agileway.ssh.client.sftp.ResponseStatusCode) SftpException(com.jn.agileway.ssh.client.sftp.exception.SftpException) NoSuchFileSftpException(com.jn.agileway.ssh.client.sftp.exception.NoSuchFileSftpException) SFTPException(com.trilead.ssh2.SFTPException)

Aggregations

NoSuchFileSftpException (com.jn.agileway.ssh.client.sftp.exception.NoSuchFileSftpException)6 SftpException (com.jn.agileway.ssh.client.sftp.exception.SftpException)5 ResponseStatusCode (com.jn.agileway.ssh.client.sftp.ResponseStatusCode)4 FileAttrs (com.jn.agileway.ssh.client.sftp.attrs.FileAttrs)2 FileMode (com.jn.agileway.ssh.client.sftp.attrs.FileMode)2 SFTPException (ch.ethz.ssh2.SFTPException)1 SFTPv3FileHandle (ch.ethz.ssh2.SFTPv3FileHandle)1 SFTPException (com.trilead.ssh2.SFTPException)1 SFTPv3FileHandle (com.trilead.ssh2.SFTPv3FileHandle)1