From 7d77f6e9fbd9ef55d8ee92aa2578c513ac3b4e53 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Fri, 13 Jun 2008 16:37:25 +0000 Subject: [PATCH] add some useful diagnostics messages when sftp fails. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@667587 13f79535-47bb-0310-9956-ffa450edef68 --- .../optional/ssh/ScpFromMessageBySftp.java | 6 +++++- .../optional/ssh/ScpToMessageBySftp.java | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) 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) {