0
我的(不完全)的代碼如下所示:匹配與andThen
def doSomething(name: String): { implicit request =>
check(name).map {
case Something() => Ok()
case SomethingElse() => NoContent
}
.andThen {
case r: Result => logger.info(s"Request finished with status ${r.header.status}")
}
}
我得到這樣一個錯誤:
[error] myfile.scala:39: fruitless type test: a value of type scala.util.Try[play.api.mvc.Result] cannot also be a play.api.mvc.Result
[error] case r: Result => logger.info(s"Request finished with status ${r.header.status}")
我怎樣才能匹配Try
?