mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +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) 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:
|
||||
final String err = "Unrecognized message: `" + msg + "`";
|
||||
@@ -202,4 +202,4 @@ public final class SCPDownloadClient extends AbstractSCPClient {
|
||||
return parts;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,8 @@ class SCPEngine {
|
||||
return;
|
||||
case 1: // Warning? not
|
||||
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:
|
||||
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