aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/sql/utils.py
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <viirya@appier.com>2015-07-19 00:32:56 -0700
committerReynold Xin <rxin@databricks.com>2015-07-19 00:32:56 -0700
commit9b644c41306cac53185ce0d2de4cb72127ada932 (patch)
treea4f15f2048fd1f02f912d34c22603b422ad80ae1 /python/pyspark/sql/utils.py
parent89d135851d928f9d7dcebe785c1b3b6a4d8dfc87 (diff)
downloadspark-9b644c41306cac53185ce0d2de4cb72127ada932.tar.gz
spark-9b644c41306cac53185ce0d2de4cb72127ada932.tar.bz2
spark-9b644c41306cac53185ce0d2de4cb72127ada932.zip
[SPARK-9166][SQL][PYSPARK] Capture and hide IllegalArgumentException in Python API
JIRA: https://issues.apache.org/jira/browse/SPARK-9166 Simply capture and hide `IllegalArgumentException` in Python API. Author: Liang-Chi Hsieh <viirya@appier.com> Closes #7497 from viirya/hide_illegalargument and squashes the following commits: 8324dce [Liang-Chi Hsieh] Fix python style. 9ace67d [Liang-Chi Hsieh] Also check exception message. 8b2ce5c [Liang-Chi Hsieh] Merge remote-tracking branch 'upstream/master' into hide_illegalargument 7be016a [Liang-Chi Hsieh] Capture and hide IllegalArgumentException in Python.
Diffstat (limited to 'python/pyspark/sql/utils.py')
-rw-r--r--python/pyspark/sql/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/python/pyspark/sql/utils.py b/python/pyspark/sql/utils.py
index cc5b2c088b..0f795ca35b 100644
--- a/python/pyspark/sql/utils.py
+++ b/python/pyspark/sql/utils.py
@@ -24,6 +24,12 @@ class AnalysisException(Exception):
"""
+class IllegalArgumentException(Exception):
+ """
+ Passed an illegal or inappropriate argument.
+ """
+
+
def capture_sql_exception(f):
def deco(*a, **kw):
try:
@@ -32,6 +38,8 @@ def capture_sql_exception(f):
s = e.java_exception.toString()
if s.startswith('org.apache.spark.sql.AnalysisException: '):
raise AnalysisException(s.split(': ', 1)[1])
+ if s.startswith('java.lang.IllegalArgumentException: '):
+ raise IllegalArgumentException(s.split(': ', 1)[1])
raise
return deco