Stringlify exception for better client debugging
This commit is contained in:
parent
2d5d58cb9f
commit
5374398050
@ -88,11 +88,12 @@ abstract class SparkOperation(spark: SparkSession, opType: OperationType, sessio
|
||||
case e: Exception =>
|
||||
if (cancel) spark.sparkContext.cancelJobGroup(statementId)
|
||||
state.synchronized {
|
||||
val errMsg = KyuubiSQLException.stringifyException(e)
|
||||
if (isTerminalState(state)) {
|
||||
warn(s"Ignore exception in terminal state with $statementId: $e")
|
||||
warn(s"Ignore exception in terminal state with $statementId: $errMsg")
|
||||
} else {
|
||||
setState(OperationState.ERROR)
|
||||
val ke = KyuubiSQLException(s"Error operating $opType: ${e.getMessage}", e)
|
||||
val ke = KyuubiSQLException(s"Error operating $opType: $errMsg", e)
|
||||
setOperationException(ke)
|
||||
throw ke
|
||||
}
|
||||
|
||||
@ -138,12 +138,10 @@ class SparkOperationSuite extends WithSparkSQLEngine {
|
||||
}
|
||||
|
||||
val e = intercept[HiveSQLException](metaData.getColumns(null, "*", null, null))
|
||||
assert(e.getCause.getMessage === "org.apache.kyuubi.KyuubiSQLException:" +
|
||||
"Error operating GET_COLUMNS: Dangling meta character '*' near index 0\n*\n^")
|
||||
assert(e.getCause.getMessage contains "Dangling meta character '*' near index 0\n*\n^")
|
||||
|
||||
val e1 = intercept[HiveSQLException](metaData.getColumns(null, null, null, "*"))
|
||||
assert(e1.getCause.getMessage === "org.apache.kyuubi.KyuubiSQLException:" +
|
||||
"Error operating GET_COLUMNS: Dangling meta character '*' near index 0\n*\n^")
|
||||
assert(e1.getCause.getMessage contains "Dangling meta character '*' near index 0\n*\n^")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.kyuubi
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import java.sql.SQLException
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
@ -147,4 +148,12 @@ object KyuubiSQLException {
|
||||
ex
|
||||
}
|
||||
|
||||
def stringifyException(e: Throwable): String = {
|
||||
val stm = new StringWriter
|
||||
val wrt = new PrintWriter(stm)
|
||||
e.printStackTrace(wrt)
|
||||
wrt.close()
|
||||
stm.toString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -122,8 +122,7 @@ trait JDBCTests extends KyuubiFunSuite {
|
||||
checkResult(metaData.getSchemas(null, "db_not_exist"), Seq.empty)
|
||||
|
||||
val e = intercept[HiveSQLException](metaData.getSchemas(null, "*"))
|
||||
assert(e.getCause.getMessage === "org.apache.kyuubi.KyuubiSQLException:" +
|
||||
"Error operating GET_SCHEMAS: Dangling meta character '*' near index 0\n*\n^")
|
||||
assert(e.getCause.getMessage contains "Dangling meta character '*' near index 0\n*\n^")
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,8 +184,7 @@ trait JDBCTests extends KyuubiFunSuite {
|
||||
}
|
||||
|
||||
val e = intercept[HiveSQLException](metaData.getTables(null, "*", null, null))
|
||||
assert(e.getCause.getMessage === "org.apache.kyuubi.KyuubiSQLException:" +
|
||||
"Error operating GET_TABLES: Dangling meta character '*' near index 0\n*\n^")
|
||||
assert(e.getCause.getMessage contains "Dangling meta character '*' near index 0\n*\n^")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user