Scala - Futures and Eithers
问题 this thread gave me an idea how to structure my code: Scala-way to handle conditions in for-comprehensions? The part in question: // First create the JSON val resultFuture: Future[Either[Failure, JsResult]] = for { userRes <- userDao.findUser(userId) user <- userRes.withFailure(UserNotFound).right authRes <- userDao.authenticate(user) auth <- authRes.withFailure(NotAuthenticated).right goodRes <- goodDao.findGood(goodId) good <- goodRes.withFailure(GoodNotFound).right checkedGood <- checkGood