From d76165a9731ebc602940c1e405479f3c9c16efad Mon Sep 17 00:00:00 2001 From: Marco F Date: Tue, 14 Nov 2023 13:33:30 +0100 Subject: [PATCH] Adding handling for repos with missing README files. Fixes #1285 --- .../src/main/scala/scaladex/client/Client.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/webclient/src/main/scala/scaladex/client/Client.scala b/modules/webclient/src/main/scala/scaladex/client/Client.scala index 836fc59fc..419f187b7 100644 --- a/modules/webclient/src/main/scala/scaladex/client/Client.scala +++ b/modules/webclient/src/main/scala/scaladex/client/Client.scala @@ -1,5 +1,6 @@ package scaladex.client +import scala.concurrent.Future import scala.scalajs.js import scala.scalajs.js.JSConverters._ import scala.scalajs.js.UndefOr @@ -47,7 +48,13 @@ object Client { } ) fetch(request).toFuture - .flatMap(res => res.text().toFuture) + .flatMap { res => + if (res.status == 200) { + res.text().toFuture + } else { + Future.successful("No README found for this project, please check the repository") + } + } .foreach { res => element.innerHTML = res