hvanhovell commented on code in PR #42377: URL: https://github.com/apache/spark/pull/42377#discussion_r1330495612
########## connector/connect/server/src/main/scala/org/apache/spark/sql/connect/utils/ErrorUtils.scala: ########## @@ -91,35 +91,40 @@ private[connect] object ErrorUtils extends Logging { private[connect] def throwableToFetchErrorDetailsResponse( st: Throwable, serverStackTraceEnabled: Boolean = false): FetchErrorDetailsResponse = { - val errorChain = traverseCauses(st).take(MAX_ERROR_CHAIN_LENGTH).map { case error => - val builder = FetchErrorDetailsResponse.Error - .newBuilder() - .setMessage(error.getMessage) - .addAllErrorTypeHierarchy(ErrorUtils.allClasses(error.getClass).map(_.getName).asJava) - - if (serverStackTraceEnabled) { - builder.addAllStackTrace( - error.getStackTrace - .map { stackTraceElement => - FetchErrorDetailsResponse.StackTraceElement - .newBuilder() - .setDeclaringClass(stackTraceElement.getClassName) - .setMethodName(stackTraceElement.getMethodName) - .setFileName(stackTraceElement.getFileName) - .setLineNumber(stackTraceElement.getLineNumber) - .build() - } - .toIterable - .asJava) - } + val errors = + traverseCauses(st).take(MAX_ERROR_CHAIN_LENGTH).zipWithIndex.map { case (error, idx) => + val builder = FetchErrorDetailsResponse.Error + .newBuilder() + .setMessage(error.getMessage) + .addAllErrorTypeHierarchy(ErrorUtils.allClasses(error.getClass).map(_.getName).asJava) + + if (idx + 1 < MAX_ERROR_CHAIN_LENGTH) { + builder.setCauseIdx(idx + 1) Review Comment: You should check if it actually has a cause instead of assuming it has one. -- 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