我想将隐式参数传递给我用recover
我的Future
s的部分函数。
def delete(id: Long) = ... { implicit something =>
serviceLayer.doSomething(id).recover(errorHandler)
}
def errorHandler: PartialFunction[Throwable, Result] = {
// I want to access the implicit parameter here
case e@SomeException(message) => ... and here
case _ => ... and here
}
答案 0 :(得分:2)
然后,您errorHandler
需要something
作为implicit parameter收到:
def delete(id: Long) = ... { implicit something =>
serviceLayer.doSomething(id).recover(errorHandler)
}
def errorHandler(implicit something: Something): PartialFunction[Throwable, Result] = {
// Access something here
case e@SomeException(message) => ... and here
case _ => ... and here
}