Skip to content

Commit

Permalink
Use string interpolation for error messages, moved comment line from …
Browse files Browse the repository at this point in the history
…original code to above its necessary code segment
  • Loading branch information
Brennon York committed Dec 31, 2014
1 parent 14daa20 commit 5e0fce1
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,21 @@ private[spark] class SparkSubmitArguments(args: Seq[String], env: Map[String, St
if (mainClass == null && !isPython && primaryResource != null) {
val uri = new URI(primaryResource)
val uriScheme = uri.getScheme()
// Note that this might still return null if no main-class is set; we catch that later

uriScheme match {
case "file" =>
try {
val jar = new JarFile(uri.getPath)
// Note that this might still return null if no main-class is set; we catch that later
mainClass = jar.getManifest.getMainAttributes.getValue("Main-Class")
} catch {
case e: Exception =>
SparkSubmit.printErrorAndExit("Cannot load main class from JAR: " + primaryResource)
SparkSubmit.printErrorAndExit(s"Cannot load main class from JAR $primaryResource")
}
case _ =>
SparkSubmit.printErrorAndExit("Cannot load main class from JAR: " + primaryResource +
" with URI: " + uriScheme)
SparkSubmit.printErrorAndExit(
s"Cannot load main class from JAR $primaryResource with URI $uriScheme. " +
"Please specify a class through --class.")
}
}

Expand Down

0 comments on commit 5e0fce1

Please sign in to comment.