Search in sources :

Example 1 with ResponseStatusCode

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

the class JschSftps method wrapSftpException.

public static SftpException wrapSftpException(com.jcraft.jsch.SftpException ex) {
    ResponseStatusCode statusCode = Enums.ofCode(ResponseStatusCode.class, ex.id);
    SftpException exception = null;
    if (statusCode == ResponseStatusCode.NO_SUCH_FILE) {
        exception = new NoSuchFileSftpException(ex);
    } else {
        exception = new SftpException(ex);
    }
    exception.setStatusCode(statusCode);
    return exception;
}
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)

Example 2 with ResponseStatusCode

use of com.jn.agileway.ssh.client.sftp.ResponseStatusCode 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(ch.ethz.ssh2.SFTPException)

Example 3 with ResponseStatusCode

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

the class SshjSftps method wrapSftpException.

public static SftpException wrapSftpException(Throwable ex) {
    if (ex instanceof SFTPException) {
        ResponseStatusCode statusCode = Enums.ofName(ResponseStatusCode.class, ((SFTPException) ex).getStatusCode().name());
        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)

Example 4 with ResponseStatusCode

use of com.jn.agileway.ssh.client.sftp.ResponseStatusCode 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

ResponseStatusCode (com.jn.agileway.ssh.client.sftp.ResponseStatusCode)4 NoSuchFileSftpException (com.jn.agileway.ssh.client.sftp.exception.NoSuchFileSftpException)4 SftpException (com.jn.agileway.ssh.client.sftp.exception.SftpException)4 SFTPException (ch.ethz.ssh2.SFTPException)1 SFTPException (com.trilead.ssh2.SFTPException)1