phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/3] phoenix git commit: PHOENIX-2396 Set root cause exception when parsing server exception
Date Wed, 11 Nov 2015 18:14:07 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 dfdcba45a -> 14580f78c


PHOENIX-2396 Set root cause exception when parsing server exception


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a722b0eb
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a722b0eb
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a722b0eb

Branch: refs/heads/4.x-HBase-0.98
Commit: a722b0eb957d599f2be164bc39ef58a5133bc19e
Parents: dfdcba4
Author: James Taylor <jamestaylor@apache.org>
Authored: Tue Nov 10 16:27:12 2015 -0800
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Wed Nov 11 09:58:37 2015 -0800

----------------------------------------------------------------------
 .../apache/phoenix/exception/SQLExceptionCode.java   |  5 ++---
 .../java/org/apache/phoenix/util/ServerUtil.java     | 15 +++++----------
 2 files changed, 7 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a722b0eb/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
index 53a13be..cc0d0ed 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
@@ -418,11 +418,10 @@ public enum SQLExceptionCode {
         }
     }
     
-    public static SQLExceptionCode fromErrorCode(int errorCode) throws SQLException {
+    public static SQLExceptionCode fromErrorCode(int errorCode) {
         SQLExceptionCode code = errorCodeMap.get(errorCode);
         if (code == null) {
-            throw new SQLExceptionInfo.Builder(SQLExceptionCode.UNKNOWN_ERROR_CODE)
-            .setMessage(Integer.toString(errorCode)).build().buildException();
+            return SQLExceptionCode.UNKNOWN_ERROR_CODE;
         }
         return code;
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a722b0eb/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java
index 0998e72..a51dc84 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java
@@ -116,21 +116,16 @@ public class ServerUtil {
     }
 
     private static SQLException parseRemoteException(Throwable t) {
-        	String message = t.getLocalizedMessage();
-        	if (message != null) {
+        String message = t.getLocalizedMessage();
+        if (message != null) {
             // If the message matches the standard pattern, recover the SQLException and
throw it.
             Matcher matcher = PATTERN.matcher(t.getLocalizedMessage());
             if (matcher.find()) {
                 int statusCode = Integer.parseInt(matcher.group(1));
-                SQLExceptionCode code;
-                try {
-                    code = SQLExceptionCode.fromErrorCode(statusCode);
-                } catch (SQLException e) {
-                    return e;
-                }
-                return new SQLExceptionInfo.Builder(code).setMessage(matcher.group()).build().buildException();
+                SQLExceptionCode code = SQLExceptionCode.fromErrorCode(statusCode);
+                return new SQLExceptionInfo.Builder(code).setMessage(matcher.group()).setRootCause(t).build().buildException();
             }
-        	}
+        }
         return null;
     }
 


Mime
View raw message