您好我想包装AskTimeOutException并发送正确的消息....
class Application @Inject()(system: ActorSystem) extends Controller {
def index = Action { Ok("Welcome")}
val ref: ActorSelection = system.actorSelection("akka.tcp://NLPSystem@127.0.0.1:5150/user/nlp")
implicit val timeout = Timeout(5 seconds)
def nlp(query: String) = Action.async {
val fut: Future[NLPResponse] = (ref ? NLPRequest(query)).mapTo[NLPResponse]
fut map {
case e: akka.pattern.AskTimeoutException => InternalServerError("NLP engine is down please try after some time")
case res: NLPResponse => Ok(res.response)
}
}
}
请建议我处理它的正确方法..