mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 23:30:55 +03:00
Merge pull request #216 from juddgaddie/master
Throw a SCPRemoteException when an error occurs on the remote server
This commit is contained in:
@@ -123,7 +123,7 @@ public final class SCPDownloadClient extends AbstractSCPClient {
|
|||||||
|
|
||||||
case (char) 1:
|
case (char) 1:
|
||||||
case (char) 2:
|
case (char) 2:
|
||||||
throw new SCPException("Remote SCP command returned error: " + msg.substring(1));
|
throw new SCPRemoteException("Remote SCP command returned error: " + msg.substring(1), msg.substring(1));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
final String err = "Unrecognized message: `" + msg + "`";
|
final String err = "Unrecognized message: `" + msg + "`";
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ class SCPEngine {
|
|||||||
return;
|
return;
|
||||||
case 1: // Warning? not
|
case 1: // Warning? not
|
||||||
case 2:
|
case 2:
|
||||||
throw new SCPException("Remote SCP command had error: " + readMessage());
|
final String remoteMessage = readMessage();
|
||||||
|
throw new SCPRemoteException("Remote SCP command had error: " + remoteMessage, remoteMessage);
|
||||||
default:
|
default:
|
||||||
throw new SCPException("Received unknown response code");
|
throw new SCPException("Received unknown response code");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.schmizz.sshj.xfer.scp;
|
||||||
|
|
||||||
|
public class SCPRemoteException extends SCPException
|
||||||
|
{
|
||||||
|
private final String remoteMessage;
|
||||||
|
|
||||||
|
public SCPRemoteException(String message, String remoteMessage) {
|
||||||
|
super(message);
|
||||||
|
this.remoteMessage = remoteMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoteMessage() {
|
||||||
|
return remoteMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user