Browse Source

[sparksql] Make error messages friendly and understandable (#2922)

- Add more context to the error along with the traceback.
Harsh Gupta 3 years ago
parent
commit
6fce8924c4
1 changed files with 7 additions and 8 deletions
  1. 7 8
      desktop/libs/notebook/src/notebook/connectors/spark_shell.py

+ 7 - 8
desktop/libs/notebook/src/notebook/connectors/spark_shell.py

@@ -293,16 +293,15 @@ class SparkApi(Api):
           'type': type
       }
     elif content['status'] == 'error':
-      tb = content.get('traceback', None)
+      msg = content.get('ename', 'unknown error')
+      evalue = content.get('evalue')
 
-      if tb is None or not tb:
-        msg = content.get('ename', 'unknown error')
+      if evalue is not None:
+        msg = '%s: %s' % (msg, ''.join(evalue))
 
-        evalue = content.get('evalue')
-        if evalue is not None:
-          msg = '%s: %s' % (msg, evalue)
-      else:
-        msg = ''.join(tb)
+      tb = content.get('traceback', None)
+      if tb is not None and tb != []:
+        msg += ' ' + ''.join(tb)
 
       raise QueryError(msg)