Reputation: 9724
The following code compiles and works as expected...
def find1(selector: JsValue): Future[Seq[String]]
def find2(selector: JsValue): Future[Seq[String]]
find1(Json.obj("name" -> "Joe")) zip
find2(Json.obj("name" -> "Tim")) map { case (result1, result2) =>
val result = result1 ++ result2
...
}
... but if I add recover
to handle possible errors like this...
find1(Json.obj("name" -> "Joe")) zip
find2(Json.obj("name" -> "Tim")) map { case (result1, result2) =>
val result = result1 ++ result2
...
}.recover { case e =>
...
}
... I always get the following error:
[error] /home/j3d/test/TestController.scala:558: missing parameter type for expanded function
[error] The argument types of an anonymous function must be fully known. (SLS 8.5)
[error] Expected type was: ?
[error] find2(Json.obj("name" -> "Tim")) map { case (result1, result2) =>
[error] ^
[error] one error found
I've tried to specify the types of result1
and result2
like this...
find1(Json.obj("name" -> "Joe")) zip
find2(Json.obj("name" -> "Tim")) map { case (result1: Seq[String], result2: Seq[String]) =>
val result = result1 ++ result2
...
}.recover { case e =>
...
}
... but nothing changes, i.e. it only compiles without recover
. Am I missing something?
Upvotes: 0
Views: 798
Reputation: 8851
use the operator notation throughout.
find1(Json.obj("name" -> "Joe")) zip
find2(Json.obj("name" -> "Tim")) map { case (result1, result2) =>
val result = result1 ++ result2
...
} recover { case e => // removed the '.'
...
}
Upvotes: 2