From 6ecd72407305a8cf985fb4cfab882b274f37d151 Mon Sep 17 00:00:00 2001
From: gmantele <gmantele@ari.uni-heidelberg.de>
Date: Tue, 25 Apr 2017 18:44:02 +0200
Subject: [PATCH] [TAP] Small correction/completion of the previous commit.

---
 src/tap/db/JDBCConnection.java | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/tap/db/JDBCConnection.java b/src/tap/db/JDBCConnection.java
index bd2d519..9ce843d 100644
--- a/src/tap/db/JDBCConnection.java
+++ b/src/tap/db/JDBCConnection.java
@@ -743,9 +743,14 @@ public class JDBCConnection implements DBConnection {
 			if (ex instanceof DBCancelledException)
 				throw (DBCancelledException)ex;
 			// Otherwise propagate the exception with an appropriate error message:
-			else if (ex instanceof SQLException)
-				throw new DBException("Unexpected error while executing a SQL query: " + ex.getMessage(), ex);
-			else if (ex instanceof TranslationException)
+			else if (ex instanceof SQLException){
+				/* ...except if the query has been aborted:
+				 * then, it is normal to receive an SQLException: */
+				if (isCancelled())
+					throw new DBCancelledException();
+				else
+					throw new DBException("Unexpected error while executing a SQL query: " + ex.getMessage(), ex);
+			}else if (ex instanceof TranslationException)
 				throw new DBException("Unexpected error while translating ADQL into SQL: " + ex.getMessage(), ex);
 			else if (ex instanceof DataReadException)
 				throw new DBException("Impossible to read the query result, because: " + ex.getMessage(), ex);
-- 
GitLab