mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
[ZEPPELIN-5103]. Simply jdbc interpreter error message
This commit is contained in:
parent
4088295639
commit
4001e1b845
2 changed files with 11 additions and 8 deletions
|
|
@ -706,18 +706,17 @@ public class JDBCInterpreter extends KerberosInterpreter {
|
|||
try {
|
||||
connection = getConnection(dbPrefix, context);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = ExceptionUtils.getStackTrace(e);
|
||||
LOGGER.error("Fail to getConnection", e);
|
||||
try {
|
||||
closeDBPool(user, dbPrefix);
|
||||
} catch (SQLException e1) {
|
||||
LOGGER.error("Cannot close DBPool for user, dbPrefix: " + user + dbPrefix, e1);
|
||||
}
|
||||
try {
|
||||
context.out.write(errorMsg);
|
||||
} catch (IOException ex) {
|
||||
throw new InterpreterException("Fail to write output", ex);
|
||||
if (e instanceof SQLException) {
|
||||
return new InterpreterResult(Code.ERROR, e.getMessage());
|
||||
} else {
|
||||
return new InterpreterResult(Code.ERROR, ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
return new InterpreterResult(Code.ERROR);
|
||||
}
|
||||
if (connection == null) {
|
||||
return new InterpreterResult(Code.ERROR, "Prefix not found.");
|
||||
|
|
@ -806,7 +805,11 @@ public class JDBCInterpreter extends KerberosInterpreter {
|
|||
}
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Cannot run " + sql, e);
|
||||
return new InterpreterResult(Code.ERROR, ExceptionUtils.getStackTrace(e));
|
||||
if (e instanceof SQLException) {
|
||||
return new InterpreterResult(Code.ERROR, e.getMessage());
|
||||
} else {
|
||||
return new InterpreterResult(Code.ERROR, ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
} finally {
|
||||
//In case user ran an insert/update/upsert statement
|
||||
if (connection != null) {
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ public class IPythonInterpreterTest extends BasePythonInterpreterTest {
|
|||
assertEquals(context.out.toInterpreterResultMessage().get(0).getData(),
|
||||
InterpreterResult.Code.SUCCESS, result.code());
|
||||
interpreterResultMessages = context.out.toInterpreterResultMessage();
|
||||
|
||||
|
||||
assertEquals(context.out.toString(), 5, interpreterResultMessages.size());
|
||||
// the first message is the warning text message.
|
||||
assertEquals(InterpreterResult.Type.HTML, interpreterResultMessages.get(1).getType());
|
||||
|
|
|
|||
Loading…
Reference in a new issue