Reputation: 345
I need to create a function that evaluates to a Route given a Future[Either[Error, T]]
I do it like this
def handleFuture[T] handleFuture(f: Future[Either[Error, T]]): Route = {
onComplete(f) {
case Failure(er) => complete(InternalServerError, err)
case Success(Left(er)) => complete(BadRequest, er)
case Success(Right(value)) => complete(OK, value)
}
}
I have implicit marshallers/unmarshaller in scope for generic type A
and I get a too many arguments for method complete
error.
What am I doing wrong?
Upvotes: 2
Views: 86
Reputation: 19517
You have a typo. Change err
to er
:
case Failure(er) => complete(InternalServerError, er)
// ^
Upvotes: 1