Return-Path: X-Original-To: apmail-drill-commits-archive@www.apache.org Delivered-To: apmail-drill-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 854481895E for ; Mon, 28 Sep 2015 18:36:20 +0000 (UTC) Received: (qmail 68277 invoked by uid 500); 28 Sep 2015 18:36:20 -0000 Delivered-To: apmail-drill-commits-archive@drill.apache.org Received: (qmail 68236 invoked by uid 500); 28 Sep 2015 18:36:20 -0000 Mailing-List: contact commits-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@drill.apache.org Delivered-To: mailing list commits@drill.apache.org Received: (qmail 68219 invoked by uid 99); 28 Sep 2015 18:36:20 -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; Mon, 28 Sep 2015 18:36:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3824AE0063; Mon, 28 Sep 2015 18:36:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: parthc@apache.org To: commits@drill.apache.org Date: Mon, 28 Sep 2015 18:36:20 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] drill git commit: DRILL-2583, DRILL-3428: Catch exceptions, and throw UserException#dataReadError with more context. This closes #161 Repository: drill Updated Branches: refs/heads/master b9afcf8fa -> c30a2687a DRILL-2583, DRILL-3428: Catch exceptions, and throw UserException#dataReadError with more context. This closes #161 + Added convenient method to UserException for String.format(...) Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/c30a2687 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/c30a2687 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/c30a2687 Branch: refs/heads/master Commit: c30a2687a653b6da9d590a8bc786cc52d518fd99 Parents: 51179b9 Author: Sudheesh Katkam Authored: Thu Sep 17 16:48:31 2015 -0700 Committer: Parth Chandra Committed: Mon Sep 28 11:35:28 2015 -0700 ---------------------------------------------------------------------- .../org/apache/drill/common/exceptions/UserException.java | 10 ++++++++++ .../apache/drill/exec/store/hbase/DrillHBaseTable.java | 8 ++++++-- .../easy/text/compliant/CompliantTextRecordReader.java | 8 ++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/c30a2687/common/src/main/java/org/apache/drill/common/exceptions/UserException.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java index b006fe3..4473ee5 100644 --- a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java +++ b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java @@ -420,6 +420,16 @@ public class UserException extends DrillRuntimeException { } /** + * add a string line to the bottom of the context + * @param value string line + * @return this builder + */ + public Builder addContext(final String value, Object... args) { + context.add(String.format(value, args)); + return this; + } + + /** * add a string value to the bottom of the context * * @param name context name http://git-wip-us.apache.org/repos/asf/drill/blob/c30a2687/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java ---------------------------------------------------------------------- diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java index ffa18e7..e98aed2 100644 --- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java +++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/DrillHBaseTable.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Set; +import org.apache.drill.common.exceptions.UserException; import org.apache.drill.exec.planner.logical.DrillTable; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.client.HBaseAdmin; @@ -30,7 +31,7 @@ import org.apache.calcite.rel.type.RelDataTypeFactory; import org.apache.calcite.sql.type.SqlTypeName; public class DrillHBaseTable extends DrillTable implements DrillHBaseConstants { - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillHBaseTable.class); + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillHBaseTable.class); private HTableDescriptor table; @@ -39,7 +40,10 @@ public class DrillHBaseTable extends DrillTable implements DrillHBaseConstants { try(HBaseAdmin admin = new HBaseAdmin(plugin.getConfig().getHBaseConf())) { table = admin.getTableDescriptor(HBaseUtils.getBytes(scanSpec.getTableName())); } catch (IOException e) { - logger.warn("Failure while loading table names for database '{}'.", storageEngineName, e); + throw UserException.dataReadError() + .message("Failure while loading table %s in database %s.", scanSpec.getTableName(), storageEngineName) + .addContext("Message: ", e.getMessage()) + .build(logger); } } http://git-wip-us.apache.org/repos/asf/drill/blob/c30a2687/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java index ad65a94..465a971 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/compliant/CompliantTextRecordReader.java @@ -17,6 +17,7 @@ */ package org.apache.drill.exec.store.easy.text.compliant; +import com.univocity.parsers.common.TextParsingException; import io.netty.buffer.DrillBuf; import java.io.IOException; @@ -134,8 +135,11 @@ public class CompliantTextRecordReader extends AbstractRecordReader { } reader.finishBatch(); return cnt; - }catch(IOException e){ - throw new DrillRuntimeException(String.format("Failure while setting up text reader for file %s. Happened at or shortly before byte position %d.", split.getPath(), reader.getPos()), e); + } catch (IOException | TextParsingException e) { + throw UserException.dataReadError(e) + .addContext("Failure while reading file %s. Happened at or shortly before byte position %d.", + split.getPath(), reader.getPos()) + .build(logger); } }