aboutsummaryrefslogtreecommitdiff
path: root/repl
diff options
context:
space:
mode:
authorAhir Reddy <ahirreddy@gmail.com>2014-10-07 22:32:39 -0700
committerPatrick Wendell <pwendell@gmail.com>2014-10-07 22:32:39 -0700
commitc7818434fa8ae8e02a0d66183990077a4ba1436c (patch)
treefa9fed0f895c4bba86557113e2bced2d10a58781 /repl
parent798ed22c289cf65f2249bf2f4250285685ca69e7 (diff)
downloadspark-c7818434fa8ae8e02a0d66183990077a4ba1436c.tar.gz
spark-c7818434fa8ae8e02a0d66183990077a4ba1436c.tar.bz2
spark-c7818434fa8ae8e02a0d66183990077a4ba1436c.zip
[SPARK-3836] [REPL] Spark REPL optionally propagate internal exceptions
Optionally have the repl throw exceptions generated by interpreted code, instead of swallowing the exception and returning it as text output. This is useful when embedding the repl, otherwise it's not possible to know when user code threw an exception. Author: Ahir Reddy <ahirreddy@gmail.com> Closes #2695 from ahirreddy/repl-throw-exceptions and squashes the following commits: bad25ee [Ahir Reddy] Style Fixes f0e5b44 [Ahir Reddy] Fixed style 0d4413d [Ahir Reddy] propogate excetions from repl
Diffstat (limited to 'repl')
-rw-r--r--repl/src/main/scala/org/apache/spark/repl/SparkIMain.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/repl/src/main/scala/org/apache/spark/repl/SparkIMain.scala b/repl/src/main/scala/org/apache/spark/repl/SparkIMain.scala
index 6ddb6accd6..646c68e60c 100644
--- a/repl/src/main/scala/org/apache/spark/repl/SparkIMain.scala
+++ b/repl/src/main/scala/org/apache/spark/repl/SparkIMain.scala
@@ -84,9 +84,11 @@ import org.apache.spark.util.Utils
* @author Moez A. Abdel-Gawad
* @author Lex Spoon
*/
- class SparkIMain(initialSettings: Settings, val out: JPrintWriter)
- extends SparkImports with Logging {
- imain =>
+ class SparkIMain(
+ initialSettings: Settings,
+ val out: JPrintWriter,
+ propagateExceptions: Boolean = false)
+ extends SparkImports with Logging { imain =>
val conf = new SparkConf()
@@ -816,6 +818,10 @@ import org.apache.spark.util.Utils
val resultName = FixedSessionNames.resultName
def bindError(t: Throwable) = {
+ // Immediately throw the exception if we are asked to propagate them
+ if (propagateExceptions) {
+ throw unwrap(t)
+ }
if (!bindExceptions) // avoid looping if already binding
throw t