You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "HyukjinKwon (via GitHub)" <gi...@apache.org> on 2023/08/22 04:34:27 UTC

[GitHub] [spark] HyukjinKwon commented on a diff in pull request #42377: [SPARK-44622][SQL][CONNECT] Implement error enrichment and setting server-side stacktrace

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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org