cloud-fan commented on code in PR #54007:
URL: https://github.com/apache/spark/pull/54007#discussion_r2734810593
##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -1424,32 +1421,19 @@ private[spark] object Utils
* below the original doTryWithCallerStacktrace which triggered it, with the
caller stack trace
* of the current caller of getTryWithCallerStacktrace.
*
- * Full stack trace of the original doTryWithCallerStacktrace caller can be
retrieved with
- * ```
- * ex.getSuppressed.find { e =>
- * e.isInstanceOf[Utils.OriginalTryStackTraceException]
- * }
- * ```
- *
- *
* @param t Try from doTryWithCallerStacktrace
* @return Result of the Try or rethrows the failure exception with modified
stacktrace.
*/
def getTryWithCallerStacktrace[T](t: Try[T]): T = t match {
+ case Failure(wrapper: OriginalTryStackTraceException) =>
+ // Unwrap to get the original exception
+ val originalEx = wrapper.getCause
+ // Stitch the stacktrace: keep the "below" part, replace "above" with
current caller
+ originalEx.setStackTrace(
Review Comment:
The more common case is people see the error once and fix the query. It's
better to optimize for the common case (no suppressed error is needed).
I agree that it's useful to know if the error was caused previously. Shall
we insert a special frame in the error stacktrace to indicate it? e.g.
```
original error stacktrace
...
doTryWithCallerStacktrace (only present if it's not the first invocation)
...
current caller stacktrace
```
--
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]