From a7721afdaead1977c78c8afb60ebd21e076a1e01 Mon Sep 17 00:00:00 2001 From: Carson Wang Date: Thu, 17 Dec 2015 15:37:23 +0800 Subject: [PATCH] Display correct error message when accessing REST API with an unknown app Id --- .../apache/spark/deploy/history/HistoryServer.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala index f31fef0eccc3b..0544fe232ccc6 100644 --- a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala +++ b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala @@ -115,7 +115,17 @@ class HistoryServer( } def getSparkUI(appKey: String): Option[SparkUI] = { - Option(appCache.get(appKey)) + try { + val ui = appCache.get(appKey) + Some(ui) + } catch { + case e: Exception => e.getCause() match { + case nsee: NoSuchElementException => + None + + case cause: Exception => throw cause + } + } } initialize()