Bug 567544 Simplify catching of DockerRequestException

As DockerRequestException is now handled in Dockerexception it is now
possible to either remove the catch-statement in case mandas's
DockerException is handled or pass the exception itself instead of
calling getResponseBody().

Change-Id: I84d07b40477f422e0c879367538d029267d1bf05
Signed-off-by: Moritz 'Morty' Strübe <moritz.struebe@mathema.de>
Reviewed-on: https://git.eclipse.org/r/c/linuxtools/org.eclipse.linuxtools/+/170203
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
Tested-by: Linux Tools Bot <linuxtools-bot@eclipse.org>
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
index 2e1db12..37eb03c 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
@@ -435,8 +435,6 @@
 			final Info info = this.client.info();
 			final Version version = this.client.version();
 			return new DockerConnectionInfo(info, version);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException
 				| InterruptedException e) {
 			throw new DockerException(Messages.Docker_General_Info_Failure, e);
@@ -743,10 +741,6 @@
 					}
 				} while (follow && !stop);
 				listContainers();
-			} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-				Activator.logErrorMessage(
-						ProcessMessages.getString("Monitor_Logs_Exception"), e); //$NON-NLS-1$
-				throw new InterruptedException();
 			} catch (org.mandas.docker.client.exceptions.DockerException
 					| IOException e) {
 				Activator.logErrorMessage(
@@ -1146,7 +1140,7 @@
 									Messages.Docker_Connection_Timeout, e));
 				}
 			} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-				throw new DockerException(e.getResponseBody());
+				throw new DockerException(e);
 			} catch (org.mandas.docker.client.exceptions.DockerException
 					| InterruptedException e) {
 				if (isOpen() && e.getCause() != null
@@ -1249,8 +1243,6 @@
 			DockerProgressHandler d = new DockerProgressHandler(handler);
 			client.pull(id, d);
 			listImages();
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			DockerException f = new DockerException(e);
 			throw f;
@@ -1266,8 +1258,6 @@
 			final DockerProgressHandler d = new DockerProgressHandler(handler);
 			client.pull(imageId, d);
 			listImages();
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			DockerException f = new DockerException(e);
 			throw f;
@@ -1299,8 +1289,6 @@
 		try {
 			DockerProgressHandler d = new DockerProgressHandler(handler);
 			client.push(name, d);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			DockerException f = new DockerException(e);
 			throw f;
@@ -1315,8 +1303,6 @@
 					.getClient(this.connectionSettings, info);
 			final DockerProgressHandler d = new DockerProgressHandler(handler);
 			client.push(name, d);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException
 				| DockerCertificateException e) {
 			DockerException f = new DockerException(e);
@@ -1329,8 +1315,6 @@
 			InterruptedException {
 		try {
 			client.removeImage(name, true, false);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			DockerException f = new DockerException(e);
 			throw f;
@@ -1342,8 +1326,6 @@
 			InterruptedException {
 		try {
 			client.removeImage(tag, false, false);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			DockerException f = new DockerException(e);
 			throw f;
@@ -1377,8 +1359,6 @@
 			final boolean force) throws DockerException, InterruptedException {
 		try {
 			client.tag(name, newTag, force);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			DockerException f = new DockerException(e);
 			throw f;
@@ -1396,8 +1376,6 @@
 			String res = getClientCopy().build(p, d,
 					BuildParam.create("forcerm", "true")); //$NON-NLS-1$ //$NON-NLS-2$
 			return res;
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException
 				| IOException e) {
 			DockerException f = new DockerException(e);
@@ -1416,8 +1394,6 @@
 			String res = getClientCopy().build(p, name, d,
 					BuildParam.create("forcerm", "true")); //$NON-NLS-1$ $NON-NLS-2$
 			return res;
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException
 				| IOException e) {
 			DockerException f = new DockerException(e);
@@ -1454,8 +1430,6 @@
 			String res = getClientCopy().build(p, name, d,
 					getBuildParameters(buildOptions));
 			return res;
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException
 				| IOException e) {
 			DockerException f = new DockerException(e);
@@ -1494,8 +1468,6 @@
 			String res = getClientCopy().build(p, name, dockerFileName, d,
 					getBuildParameters(buildOptions));
 			return res;
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException
 				| IOException e) {
 			DockerException f = new DockerException(e);
@@ -1674,8 +1646,6 @@
 			return id;
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}
@@ -1697,8 +1667,6 @@
 			listContainers();
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}
@@ -1735,8 +1703,6 @@
 			listContainers(); // update container list
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}
@@ -1769,8 +1735,6 @@
 			listContainers(); // update container list
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}
@@ -1785,8 +1749,6 @@
 			listContainers(); // update container list
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}
@@ -1932,8 +1894,6 @@
 			listContainers();
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}
@@ -1952,8 +1912,6 @@
 			// FIXME: are we refreshing the list of images twice ?
 			listImages();
 			getImages(true);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException
 				| InterruptedException e) {
 			throw new DockerException(e);
@@ -2132,8 +2090,6 @@
 			}
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}
@@ -2181,8 +2137,6 @@
 			return exit;
 		} catch (ContainerNotFoundException e) {
 			throw new DockerContainerNotFoundException(e);
-		} catch (org.mandas.docker.client.exceptions.DockerRequestException e) {
-			throw new DockerException(e.getResponseBody());
 		} catch (org.mandas.docker.client.exceptions.DockerException e) {
 			throw new DockerException(e);
 		}