juliuszsompolski commented on code in PR #54007:
URL: https://github.com/apache/spark/pull/54007#discussion_r2732237258


##########
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:
   IIUC, at this point, the original above stack trace is lost, and also it's 
indistinguishable for the user, whether the exception happened here, or was 
only retrieved and stitched from an earlier call?
   I do find it useful for debugging to know if the exception really happened 
on the stack trace of the current call, or it happened in a different call and 
it was only stitched to pretend as happening here, while in fact it was 
retrieved from a Try....
   
   I like the wrapper change that makes it cleaner than searching for 
`OriginalTryStackTraceException` among the supressed, but I personally would 
prefer to preserve and show the information about the original place the 
exception was thrown... However, I can not think of a different way to add it 
than again adding it as a suppressed Exception, which would then have both a 
wrapper and a suppressed exception, so I don't think it would be an improvement 
to the current state...



-- 
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]

Reply via email to