diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java index 9b54b08a7..3669e3f2e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java @@ -94,7 +94,11 @@ public class ScpFromMessageBySftp extends ScpFromMessage { } getDir(channel, remoteFile, localFile); } catch (SftpException e) { - throw new JSchException(e.toString()); + JSchException schException = new JSchException("Could not get '"+ remoteFile + +"' to '"+localFile+"' - " + +e.toString()); + schException.initCause(e); + throw schException; } finally { if (channel != null) { channel.disconnect(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java index 409f85b39..767b172f0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java @@ -134,7 +134,11 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ { try { sendFileToRemote(channel, localFile, remotePath); } catch (SftpException e) { - throw new JSchException(e.toString()); + JSchException schException = new JSchException("Could not send '" + localFile + + "' to '" + remotePath + "' - " + + e.toString()); + schException.initCause(e); + throw schException; } } finally { if (channel != null) { @@ -150,12 +154,23 @@ public class ScpToMessageBySftp extends ScpToMessage/*AbstractSshMessage*/ { try { channel.cd(remotePath); + } catch (SftpException e) { + JSchException schException = new JSchException("Could not CD to '" + remotePath + "' - " + e.toString()); + schException.initCause(e); + throw schException; + } + try { for (Iterator i = directoryList.iterator(); i.hasNext();) { Directory current = (Directory) i.next(); + if(getVerbose()) { + log("Sending directory " + current); + } sendDirectory(channel, current); } } catch (SftpException e) { - throw new JSchException(e.toString()); + JSchException schException = new JSchException(e.toString()); + schException.initCause(e); + throw schException; } } finally { if (channel != null) {