From 8b2f3fcc0404cbf8463d6b4f4646fc88ba32502b Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Sat, 23 Jan 2016 15:42:09 +0100 Subject: [PATCH] Better error message on 404 Not Found Fixes https://github.com/alexarchambault/coursier/issues/111 --- cache/src/main/scala/coursier/Cache.scala | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cache/src/main/scala/coursier/Cache.scala b/cache/src/main/scala/coursier/Cache.scala index f1383745e..1675bb890 100644 --- a/cache/src/main/scala/coursier/Cache.scala +++ b/cache/src/main/scala/coursier/Cache.scala @@ -122,18 +122,23 @@ object Cache { logger.foreach(_.downloadingArtifact(url, file)) val res = - try f - catch { case e: Exception => - logger.foreach(_.downloadedArtifact(url, success = false)) - throw e + try \/-(f) + catch { + case nfe: FileNotFoundException if nfe.getMessage != null => + logger.foreach(_.downloadedArtifact(url, success = false)) + -\/(-\/(FileError.NotFound(nfe.getMessage))) + case e: Exception => + logger.foreach(_.downloadedArtifact(url, success = false)) + throw e } finally { urlLocks.remove(url) } - logger.foreach(_.downloadedArtifact(url, success = true)) + for (res0 <- res) + logger.foreach(_.downloadedArtifact(url, success = res0.isRight)) - res + res.merge } else -\/(FileError.ConcurrentDownload(url)) }