Skip to content

Commit

Permalink
Adding handling for repos with missing README files. Fixes scalacente…
Browse files Browse the repository at this point in the history
  • Loading branch information
mfirry committed Nov 14, 2023
1 parent 13ec905 commit d76165a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d76165a

Please sign in to comment.