You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/16 15:29:32 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #37520: [SPARK-40098][SQL] Format error messages in the Thrift Server

cloud-fan commented on code in PR #37520:
URL: https://github.com/apache/spark/pull/37520#discussion_r946933016


##########
core/src/main/scala/org/apache/spark/SparkThrowableHelper.scala:
##########
@@ -135,4 +143,41 @@ private[spark] object SparkThrowableHelper {
   def isInternalError(errorClass: String): Boolean = {
     errorClass == "INTERNAL_ERROR"
   }
+
+  def getMessage(e: SparkThrowable with Throwable, format: ErrorMessageFormat.Value): String = {
+    import ErrorMessageFormat._
+    format match {
+      case PRETTY => e.getMessage
+      case MINIMAL | STANDARD if e.getErrorClass == null =>
+        val jValue = ("errorClass" -> "legacy") ~
+          ("messageParameters" -> JObject(List("message" -> JString(e.getMessage)))) ~
+          ("queryContext" -> JArray(List.empty))
+        compact(render(jValue))
+      case MINIMAL | STANDARD =>
+        val errorClass = e.getErrorClass
+        val message = if (format == STANDARD) {
+          val errorInfo = errorClassToInfoMap.getOrElse(errorClass,
+            throw new IllegalArgumentException(s"Cannot find error class '$errorClass'"))

Review Comment:
   let's use the new `SparkException.internalError`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org