From 67edbae1899291441053d43915b53d686378e6e9 Mon Sep 17 00:00:00 2001 From: Michael Valenta Date: Thu, 2 Dec 2004 12:31:48 +0000 Subject: Bug 78989 Unfriendly message when working disconnected --- .../team/internal/ccvs/core/messages.properties | 1 + .../ccvs/ssh2/CVSSSH2ServerConnection.java | 36 ++++++++++++++-------- .../team/internal/ccvs/ssh2/messages.properties | 1 + 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties index 4ee3099b4..66e52a7d8 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties @@ -48,6 +48,7 @@ java.io.InterruptedIOException=I/O has been interrupted. java.net.UnknownHostException=Cannot locate host: {0} java.net.ConnectException=Cannot connect to host: {0} java.net.SocketException=Socket Exception: {0} +java.net.NoRouteToHostException={0} Connection.cannotClose=Cannot close connection Connection.readUnestablishedConnection=Failure due to attempt to read from an unestablished connection diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java index 9cf102bc5..ea787fba3 100644 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java +++ b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java @@ -9,26 +9,18 @@ * implementation. ******************************************************************************/ package org.eclipse.team.internal.ccvs.ssh2; -import java.io.FilterInputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; +import java.net.NoRouteToHostException; +import java.net.UnknownHostException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; import org.eclipse.team.internal.ccvs.core.IServerConnection; import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; import org.eclipse.team.internal.ccvs.ssh.SSHServerConnection; -import org.eclipse.team.internal.core.streams.PollingInputStream; -import org.eclipse.team.internal.core.streams.PollingOutputStream; -import org.eclipse.team.internal.core.streams.TimeoutInputStream; -import org.eclipse.team.internal.core.streams.TimeoutOutputStream; +import org.eclipse.team.internal.core.streams.*; -import com.jcraft.jsch.Channel; -import com.jcraft.jsch.ChannelExec; -import com.jcraft.jsch.JSchException; -import com.jcraft.jsch.Session; +import com.jcraft.jsch.*; /** * SSH2 connection method. Has the property of defaulting to SSH1 if the server @@ -152,6 +144,24 @@ public class CVSSSH2ServerConnection implements IServerConnection { if (message.equals("Auth fail")) { //$NON-NLS-1$ message = Policy.bind("CVSSSH2ServerConnection.0"); //$NON-NLS-1$ // Could possibly retry below but wont just in case + } else if (message.startsWith("Session.connect: ")) { //$NON-NLS-1$ + // Jsh has messages formatted like "Session.connect: java.net.NoRouteToHostException: ..." + // Strip of the exception and try to convert it to a more meaningfull string + int start = message.indexOf(": ") + 1; //$NON-NLS-1$ + if (start != -1) { + int end = message.indexOf(": ", start); //$NON-NLS-1$ + if (end != -1) { + String exception = message.substring(start, end).trim(); + if (exception.indexOf("NoRouteToHostException") != -1) { //$NON-NLS-1$ + message = Policy.bind("CVSSSH2ServerConnection.1", location.getHost()); //$NON-NLS-1$ + throw new NoRouteToHostException(message); + } else if (exception.indexOf("java.net.UnknownHostException") != -1) { //$NON-NLS-1$ + throw new UnknownHostException(location.getHost()); + } else { + message = message.substring(end + 1).trim(); + } + } + } } throw new CVSAuthenticationException(message, CVSAuthenticationException.NO_RETRY); } diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties index 290c8fb04..675bd9412 100644 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties +++ b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties @@ -80,6 +80,7 @@ CVSSSH2PreferencePage.110=Remote sshd is not from OpenSSH. CVSSSH2PreferencePage.111=Failed to export ssh key to remote server. CVSSSH2ServerConnection.3=session is down CVSSSH2ServerConnection.0=An undetermined authentication failure has occurred +CVSSSH2ServerConnection.1=No route to host {0} could be found CVSSSH2PreferencePage.info=Information CVSSSH2PreferencePage.warning=Warning CVSSSH2PreferencePage.information=Information -- cgit v1.2.3