Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21454#discussion_r191944797
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkConf.scala ---
    @@ -448,6 +473,22 @@ class SparkConf(loadDefaults: Boolean) extends 
Cloneable with Logging with Seria
        */
       private[spark] def getenv(name: String): String = System.getenv(name)
     
    +  /**
    +   * Wrapper method for get() methods which require some specific value 
format. This catches
    +   * any [[NumberFormatException]] or [[IllegalArgumentException]] and 
re-raises it with the
    +   * incorrectly configured key in the exception message.
    +   */
    +  private def catchIllegalValue[T](key: String)(getValue: => T): T = {
    +    try {
    +      getValue
    +    } catch {
    +      case e: NumberFormatException =>
    +        throw new NumberFormatException(s"Illegal value for config key 
$key: ${e.getMessage}")
    --- End diff --
    
    nit: please also add the cause like `throw new 
NumberFormatException(s"Illegal value for config key $key: ${e.getMessage}", e)`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to