Skip to content

Commit

Permalink
Address more PR comments
Browse files Browse the repository at this point in the history
 * Remove extra space in tests
 * Add cause to thrown exceptions
  • Loading branch information
PenguinToast committed May 30, 2018
1 parent c1b4d16 commit b7ff38f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion core/src/main/scala/org/apache/spark/SparkConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,11 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging with Seria
getValue
} catch {
case e: NumberFormatException =>
// NumberFormatException doesn't have a constructor that takes a cause for some reason.
throw new NumberFormatException(s"Illegal value for config key $key: ${e.getMessage}")
.initCause(e)
case e: IllegalArgumentException =>
throw new IllegalArgumentException(s"Illegal value for config key $key: ${e.getMessage}")
throw new IllegalArgumentException(s"Illegal value for config key $key: ${e.getMessage}", e)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/org/apache/spark/SparkConfSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class SparkConfSuite extends SparkFunSuite with LocalSparkContext with ResetSyst
val key = "SomeKey"
val conf = new SparkConf()
conf.set(key, "SomeInvalidValue")
val thrown = intercept [IllegalArgumentException] {
val thrown = intercept[IllegalArgumentException] {
getValue(conf, key)
}
assert(thrown.getMessage.contains(key))
Expand Down

0 comments on commit b7ff38f

Please sign in to comment.