You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by jo...@apache.org on 2016/09/06 15:41:17 UTC

zeppelin git commit: [ZEPPELIN-1116]send out more exception msg

Repository: zeppelin
Updated Branches:
  refs/heads/master 20f0e5bac -> 09870cc6c


[ZEPPELIN-1116]send out more exception msg

### What is this PR for?
better jdbc error msg make people know the true error clearly.

### What type of PR is it?
Improvement

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1116

### How should this be tested?
Outline the steps to test the PR here.

### Screenshots (if appropriate)
![image](https://cloud.githubusercontent.com/assets/168310/18045048/68e41d14-6e03-11e6-9a8b-25acd00f6684.png)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

in sql case, the real error exception stack is hide in e.getCause.getCause. use printStackTrace to receive all the stack trace make people know true reason.

Author: passionke <ke...@gmail.com>

Closes #1379 from passionke/passionke-jdbc-better-errortips and squashes the following commits:

a1735ed [passionke] Update JDBCInterpreter.java
3d56183 [passionke] import java.io
0e2010d [passionke] send out more exception msg


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

Branch: refs/heads/master
Commit: 09870cc6cf0f34581166fe4d70852d0a2f6b8c16
Parents: 20f0e5b
Author: passionke <ke...@gmail.com>
Authored: Tue Aug 30 03:13:26 2016 +0800
Committer: Jongyoul Lee <jo...@apache.org>
Committed: Wed Sep 7 00:41:03 2016 +0900

----------------------------------------------------------------------
 .../java/org/apache/zeppelin/jdbc/JDBCInterpreter.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/09870cc6/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
index 0eb0dff..68a1ce4 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -15,7 +15,8 @@
 package org.apache.zeppelin.jdbc;
 
 import static org.apache.commons.lang.StringUtils.containsIgnoreCase;
-
+import java.io.*;
+import java.nio.charset.StandardCharsets;
 import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
@@ -418,11 +419,11 @@ public class JDBCInterpreter extends Interpreter {
 
     } catch (Exception e) {
       logger.error("Cannot run " + sql, e);
-      StringBuilder stringBuilder = new StringBuilder();
-      stringBuilder.append(e.getMessage()).append("\n");
-      stringBuilder.append(e.getClass().toString()).append("\n");
-      stringBuilder.append(StringUtils.join(e.getStackTrace(), "\n"));
-      return new InterpreterResult(Code.ERROR, stringBuilder.toString());
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      PrintStream ps = new PrintStream(baos);
+      e.printStackTrace(ps);
+      String errorMsg = new String(baos.toByteArray(), StandardCharsets.UTF_8);
+      return new InterpreterResult(Code.ERROR, errorMsg);
     }
   }