gengliangwang commented on code in PR #36612:
URL: https://github.com/apache/spark/pull/36612#discussion_r877015458
##########
core/src/main/scala/org/apache/spark/ErrorInfo.scala:
##########
@@ -77,20 +77,25 @@ private[spark] object SparkThrowableHelper {
queryContext: String = ""): String = {
val errorInfo = errorClassToInfoMap.getOrElse(errorClass,
throw new IllegalArgumentException(s"Cannot find error class
'$errorClass'"))
- if (errorInfo.subClass.isDefined) {
+ val (displayClass, displayMessageParameters, displayFormat) = if
(errorInfo.subClass.isEmpty) {
+ (errorClass, messageParameters, errorInfo.messageFormat)
+ } else {
val subClass = errorInfo.subClass.get
val subErrorClass = messageParameters.head
val errorSubInfo = subClass.getOrElse(subErrorClass,
throw new IllegalArgumentException(s"Cannot find sub error class
'$subErrorClass'"))
- val subMessageParameters = messageParameters.tail
- "[" + errorClass + "." + subErrorClass + "] " +
String.format((errorInfo.messageFormat +
- errorSubInfo.messageFormat).replaceAll("<[a-zA-Z0-9_-]+>", "%s"),
- subMessageParameters: _*) + queryContext
+ (errorClass + "." + subErrorClass, messageParameters.tail,
+ errorInfo.messageFormat + errorSubInfo.messageFormat)
+ }
+ val displayMessage = String.format(
+ displayFormat.replaceAll("<[a-zA-Z0-9_-]+>", "%s"),
Review Comment:
Here we avoid writing `.replaceAll("<[a-zA-Z0-9_-]+>", "%s")` twice
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]