[EGIT PATCH 23/23] Use new TransportException constructors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modify existing TransportException constructor calls to new ones with
URI as argument.

Signed-off-by: Marek Zawirski <marek.zawirski@xxxxxxxxx>
---
 .../spearce/jgit/transport/BasePackConnection.java |    6 +++---
 .../jgit/transport/BasePackPushConnection.java     |   12 ++++++------
 .../org/spearce/jgit/transport/PushProcess.java    |    6 +++---
 .../spearce/jgit/transport/TransportGitAnon.java   |   15 +++++++--------
 .../spearce/jgit/transport/TransportGitSsh.java    |   18 ++++++++----------
 .../org/spearce/jgit/transport/TransportLocal.java |    3 +--
 .../org/spearce/jgit/transport/TransportSftp.java  |   12 +++++-------
 7 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
index d119672..9b39ebc 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
@@ -125,7 +125,7 @@ abstract class BasePackConnection extends BaseConnection {
 				line = pckIn.readString();
 			} catch (EOFException eof) {
 				if (avail.isEmpty())
-					throw new TransportException(uri + " not found.");
+					throw new TransportException(uri, "not found.");
 				throw eof;
 			}
 
@@ -155,7 +155,7 @@ abstract class BasePackConnection extends BaseConnection {
 				name = name.substring(0, name.length() - 3);
 				final Ref prior = avail.get(name);
 				if (prior == null)
-					throw new PackProtocolException(uri + ": advertisement of "
+					throw new PackProtocolException(uri, "advertisement of "
 							+ name + "^{} came before " + name);
 
 				if (prior.getPeeledObjectId() != null)
@@ -185,7 +185,7 @@ abstract class BasePackConnection extends BaseConnection {
 	}
 
 	private PackProtocolException duplicateAdvertisement(final String name) {
-		return new PackProtocolException(uri + ": duplicate advertisements of "
+		return new PackProtocolException(uri, "duplicate advertisements of "
 				+ name);
 	}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java
index 159e331..c56605a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java
@@ -110,7 +110,7 @@ class BasePackPushConnection extends BasePackConnection implements
 		} catch (TransportException e) {
 			throw e;
 		} catch (Exception e) {
-			throw new TransportException(uri + ": " + e.getMessage(), e);
+			throw new TransportException(uri, e.getMessage(), e);
 		} finally {
 			close();
 		}
@@ -146,7 +146,7 @@ class BasePackPushConnection extends BasePackConnection implements
 		}
 
 		if (monitor.isCancelled())
-			throw new TransportException(uri + ": push cancelled");
+			throw new TransportException(uri, "push cancelled");
 		pckOut.end();
 	}
 
@@ -179,13 +179,13 @@ class BasePackPushConnection extends BasePackConnection implements
 			throws IOException {
 		final String unpackLine = pckIn.readString();
 		if (!unpackLine.startsWith("unpack "))
-			throw new PackProtocolException(uri + ": unexpected report line: "
+			throw new PackProtocolException(uri, "unexpected report line: "
 					+ unpackLine);
 		final String unpackStatus = unpackLine.substring("unpack ".length());
 		if (!unpackStatus.equals("ok"))
-			throw new TransportException(uri
-					+ ": error occurred during unpacking on the remote end: "
-					+ unpackStatus);
+			throw new TransportException(uri,
+					"error occurred during unpacking on the remote end: "
+							+ unpackStatus);
 
 		String refLine;
 		while ((refLine = pckIn.readString()).length() > 0) {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/PushProcess.java b/org.spearce.jgit/src/org/spearce/jgit/transport/PushProcess.java
index f742949..1b5f9c6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/PushProcess.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/PushProcess.java
@@ -178,9 +178,9 @@ class PushProcess {
 			} catch (MissingObjectException x) {
 				fastForward = false;
 			} catch (Exception x) {
-				throw new TransportException(transport.getURI()
-						+ ": reading objects from local repository failed: "
-						+ x.getMessage(), x);
+				throw new TransportException(transport.getURI(),
+						"reading objects from local repository failed: "
+								+ x.getMessage(), x);
 			}
 			rru.setFastForward(fastForward);
 			if (!fastForward && !rru.isForceUpdate())
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitAnon.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitAnon.java
index 6e49083..8a78099 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitAnon.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitAnon.java
@@ -82,12 +82,11 @@ class TransportGitAnon extends PackTransport {
 		try {
 			return new Socket(InetAddress.getByName(uri.getHost()), port);
 		} catch (IOException c) {
-			final String us = uri.toString();
 			if (c instanceof UnknownHostException)
-				throw new TransportException(us + ": Unknown host");
+				throw new TransportException(uri, "unknown host");
 			if (c instanceof ConnectException)
-				throw new TransportException(us + ": " + c.getMessage());
-			throw new TransportException(us + ": " + c.getMessage(), c);
+				throw new TransportException(uri, c.getMessage());
+			throw new TransportException(uri, c.getMessage(), c);
 		}
 	}
 
@@ -116,8 +115,8 @@ class TransportGitAnon extends PackTransport {
 				service("git-upload-pack", pckOut);
 			} catch (IOException err) {
 				close();
-				throw new TransportException(uri.toString()
-						+ ": remote hung up unexpectedly", err);
+				throw new TransportException(uri,
+						"remote hung up unexpectedly", err);
 			}
 			readAdvertisedRefs();
 		}
@@ -149,8 +148,8 @@ class TransportGitAnon extends PackTransport {
 				service("git-receive-pack", pckOut);
 			} catch (IOException err) {
 				close();
-				throw new TransportException(uri.toString()
-						+ ": remote hung up unexpectedly", err);
+				throw new TransportException(uri,
+						"remote hung up unexpectedly", err);
 			}
 			readAdvertisedRefs();
 		}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java
index 55be4f6..46c60c3 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java
@@ -162,13 +162,12 @@ class TransportGitSsh extends PackTransport {
 				session.connect();
 			return session;
 		} catch (JSchException je) {
-			final String us = uri.toString();
 			final Throwable c = je.getCause();
 			if (c instanceof UnknownHostException)
-				throw new TransportException(us + ": Unknown host");
+				throw new TransportException(uri, "unknown host");
 			if (c instanceof ConnectException)
-				throw new TransportException(us + ": " + c.getMessage());
-			throw new TransportException(us + ": " + je.getMessage(), je);
+				throw new TransportException(uri, c.getMessage());
+			throw new TransportException(uri, je.getMessage(), je);
 		}
 	}
 
@@ -189,8 +188,7 @@ class TransportGitSsh extends PackTransport {
 			channel.connect();
 			return channel;
 		} catch (JSchException je) {
-			throw new TransportException(uri.toString() + ": "
-					+ je.getMessage(), je);
+			throw new TransportException(uri, je.getMessage(), je);
 		}
 	}
 
@@ -210,8 +208,8 @@ class TransportGitSsh extends PackTransport {
 				throw err;
 			} catch (IOException err) {
 				close();
-				throw new TransportException(uri.toString()
-						+ ": remote hung up unexpectedly", err);
+				throw new TransportException(uri,
+						"remote hung up unexpectedly", err);
 			}
 			readAdvertisedRefs();
 		}
@@ -255,8 +253,8 @@ class TransportGitSsh extends PackTransport {
 				throw err;
 			} catch (IOException err) {
 				close();
-				throw new TransportException(uri.toString()
-						+ ": remote hung up unexpectedly", err);
+				throw new TransportException(uri,
+						"remote hung up unexpectedly", err);
 			}
 			readAdvertisedRefs();
 		}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
index f48dc6d..761d1b8 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
@@ -99,8 +99,7 @@ class TransportLocal extends PackTransport {
 			new StreamRewritingThread(proc.getErrorStream()).start();
 			return proc;
 		} catch (IOException err) {
-			throw new TransportException(uri.toString() + ": "
-					+ err.getMessage(), err);
+			throw new TransportException(uri, err.getMessage(), err);
 		}
 	}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java
index cfe22c1..21657ef 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java
@@ -111,13 +111,12 @@ class TransportSftp extends WalkTransport {
 				session.connect();
 			return session;
 		} catch (JSchException je) {
-			final String us = uri.toString();
 			final Throwable c = je.getCause();
 			if (c instanceof UnknownHostException)
-				throw new TransportException(us + ": Unknown host");
+				throw new TransportException(uri, "unknown host");
 			if (c instanceof ConnectException)
-				throw new TransportException(us + ": " + c.getMessage());
-			throw new TransportException(us + ": " + je.getMessage(), je);
+				throw new TransportException(uri, c.getMessage());
+			throw new TransportException(uri, je.getMessage(), je);
 		}
 	}
 
@@ -127,8 +126,7 @@ class TransportSftp extends WalkTransport {
 			channel.connect();
 			return (ChannelSftp) channel;
 		} catch (JSchException je) {
-			throw new TransportException(uri.toString() + ": "
-					+ je.getMessage(), je);
+			throw new TransportException(uri, je.getMessage(), je);
 		}
 	}
 
@@ -259,7 +257,7 @@ class TransportSftp extends WalkTransport {
 			} catch (FileNotFoundException notPacked) {
 				// Perhaps it wasn't worthwhile, or is just an older repository.
 			} catch (IOException e) {
-				throw new TransportException(uri + ": error in packed-refs", e);
+				throw new TransportException(uri, "error in packed-refs", e);
 			}
 			readRef(avail, "../HEAD", "HEAD");
 			readLooseRefs(avail, "../refs", "refs/");
-- 
1.5.5.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux