Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 270C118825 for ; Wed, 11 Nov 2015 00:27:39 +0000 (UTC) Received: (qmail 15913 invoked by uid 500); 11 Nov 2015 00:27:39 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 15872 invoked by uid 500); 11 Nov 2015 00:27:39 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 15863 invoked by uid 99); 11 Nov 2015 00:27:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Nov 2015 00:27:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CDA42E0615; Wed, 11 Nov 2015 00:27:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jamestaylor@apache.org To: commits@phoenix.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-2396 Set root cause exception when parsing server exception Date: Wed, 11 Nov 2015 00:27:38 +0000 (UTC) Repository: phoenix Updated Branches: refs/heads/master 8a5046e40 -> 519f9e056 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/519f9e05 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/519f9e05 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/519f9e05 Branch: refs/heads/master Commit: 519f9e0561b42d3499dec9c1247a1050fa26a78b Parents: 8a5046e Author: James Taylor Authored: Tue Nov 10 16:27:12 2015 -0800 Committer: James Taylor Committed: Tue Nov 10 16:27:12 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/519f9e05/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/519f9e05/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; }