Merge pull request #216 from juddgaddie/master

Throw a SCPRemoteException when an error occurs on the remote server
This commit is contained in:
Jeroen van Erp
2015-10-28 22:46:51 +01:00
3 changed files with 19 additions and 3 deletions

View File

@@ -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 + "`";

View File

@@ -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");
} }

View File

@@ -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;
}
}