HyukjinKwon commented on code in PR #42377:
URL: https://github.com/apache/spark/pull/42377#discussion_r1300891376


##########
python/pyspark/errors/exceptions/connect.py:
##########
@@ -45,14 +47,34 @@ class SparkConnectException(PySparkException):
     """
 
 
-def convert_exception(info: "ErrorInfo", message: str) -> 
SparkConnectException:
+def convert_exception(
+    info: "ErrorInfo", message: str, stub: "SparkConnectServiceStub"
+) -> SparkConnectException:
     classes = []
     if "classes" in info.metadata:
         classes = json.loads(info.metadata["classes"])
 
+    stack_trace = ""
+
     if "stackTrace" in info.metadata:
-        stackTrace = info.metadata["stackTrace"]
-        message += f"\n\nJVM stacktrace:\n{stackTrace}"
+        stack_trace = info.metadata["stackTrace"]
+
+    if "userId" in info.metadata and "sessionId" in info.metadata and 
"errorId" in info.metadata:
+        req = pb2.GetErrorInfoRequest()
+        req.user_context.user_id = info.metadata["userId"]
+        req.session_id = info.metadata["sessionId"]
+        req.error_ids.append(info.metadata["errorId"])
+
+        try:
+            result = GetErrorInfoResult.fromProto(stub.GetErrorInfo(req))
+            if result is not None and result.error_id == 
info.metadata["errorId"]:
+                message = result.message
+                stack_trace = result.stack_trace
+        except (Exception,):

Review Comment:
   ```suggestion
           except Exception:
   ```
   
   Which exception do we expect to ignore here? Would be great if we can catch 
narrower scope.



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