[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
This commit is contained in:
Ahir Reddy 2014-10-07 22:32:39 -07:00 committed by Patrick Wendell
parent 798ed22c28
commit c7818434fa

View file

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