From 420a765dc41158ebef9261a1fe2ce589d9a8c5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0est=C3=A1k=20V=C3=ADt?= Date: Wed, 28 Jun 2017 09:15:55 +0200 Subject: [PATCH] Added a proper error message for a missing library --- app/controllers/Statistics.scala | 8 ++++---- app/views/libraryNotFound.scala.html | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 app/views/libraryNotFound.scala.html diff --git a/app/controllers/Statistics.scala b/app/controllers/Statistics.scala index 6a9058c..d5a2c4e 100644 --- a/app/controllers/Statistics.scala +++ b/app/controllers/Statistics.scala @@ -318,10 +318,10 @@ class Statistics @Inject()( val (lastRefreshTime, resultsFuture) = projectReportsProvider.resultsForVersions(versions) resultsFuture flatMap { allResults => select(allResults, selectorOption).fold(Future.successful(notFound())) { selection => - Future.successful(Ok(views.html.library( - dep = selection.result.groupedDependenciesByHashes(depId), - selectorOption = selectorOption - ))) + Future.successful(selection.result.groupedDependenciesByHashes.get(depId) match { + case None => NotFound(views.html.libraryNotFound(depId = depId, selectorOption = selectorOption)) + case Some(dep) => Ok(views.html.library(dep = dep, selectorOption = selectorOption)) + }) } } } diff --git a/app/views/libraryNotFound.scala.html b/app/views/libraryNotFound.scala.html new file mode 100644 index 0000000..024ff5f --- /dev/null +++ b/app/views/libraryNotFound.scala.html @@ -0,0 +1,5 @@ +@import com.ysoft.odc.Hashes +@(depId: Hashes, selectorOption: Option[String])(implicit header: DefaultRequest, mainTemplateData: MainTemplateData) +@main(title=s"Unknown library"){ + There is no library found for hashes @depId.hashTuples.map{case (hashType, hashValue) => @hashType=@hashValue}.mkString(", "). It might have been removed or updated to a newer version. +} \ No newline at end of file