Better error message on 404 Not Found

Fixes https://github.com/alexarchambault/coursier/issues/111
This commit is contained in:
Alexandre Archambault 2016-01-23 15:42:09 +01:00
parent 22fd372b0e
commit 8b2f3fcc04
1 changed files with 11 additions and 6 deletions

View File

@ -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))
}