heyihong commented on code in PR #42377: URL: https://github.com/apache/spark/pull/42377#discussion_r1323024042
########## connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala: ########## @@ -90,33 +218,34 @@ private[client] object GrpcExceptionConverter extends JsonUtils { new SparkArrayIndexOutOfBoundsException(message)), errorConstructor[DateTimeException]((message, _) => new SparkDateTimeException(message)), errorConstructor((message, cause) => new SparkRuntimeException(message, cause)), - errorConstructor((message, cause) => new SparkUpgradeException(message, cause))) - - private def errorInfoToThrowable(info: ErrorInfo, message: String): Option[Throwable] = { - val classes = - mapper.readValue(info.getMetadataOrDefault("classes", "[]"), classOf[Array[String]]) - - classes - .find(errorFactory.contains) - .map { cls => - val constructor = errorFactory.get(cls).get - constructor(message, None) - } - } - - private def toThrowable(ex: StatusRuntimeException): Throwable = { - val status = StatusProto.fromThrowable(ex) - - val fallbackEx = new SparkException(ex.toString, ex.getCause) - - val errorInfoOpt = status.getDetailsList.asScala - .find(_.is(classOf[ErrorInfo])) - - if (errorInfoOpt.isEmpty) { - return fallbackEx + errorConstructor((message, cause) => new SparkUpgradeException(message, cause)), + errorConstructor((message, cause) => new SparkException(message, cause.orNull))) + + private case class Error( + classHierarchy: Array[String], + message: String, + stackTraceOpt: Option[Array[StackTraceElement]], + causeOpt: Option[Error]) + + private def errorToThrowable(error: Error): Option[Throwable] = { Review Comment: The error framework is for improving the quality of error messages. Currently, we directly construct exception by message and cause and don't retain the relevant fields like errorClass, query context and so on. The current implementation should be extensible to the error framework and I will follow up on this to cover the relevant use cases -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org