Spray documentation has example about onComplete directive
I copied example:
path("divide" / IntNumber / IntNumber) { (a, b) =>
onComplete(divide(a, b)) {
case Success(value: Any) => complete(s"The result was $value")
case Failure(ex) => complete(StatusCodes.InternalServerError, s"An error occurred: ${ex.getMessage}")
}
}
def divide(a: Int, b: Int): Future[Int] = Future {
a / b
}
And I got error:
Type mismatch, expected: onCompleteFutureMagnet[NoninferedT], actual Future[Int]
It is seems that something very simple missed in code.
Spray version is 1.3.1
Updated
I have downloaded spray sources and see same compilation errors in FutureDirectivesSpec.
ExecutionContextis in scope. If you are seeing the same problem compiling spray itself, can you post the exact steps you took for compiling spray? - jrudolph