我想将一个隐式参数传递给用于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
}
然后errorHandler
需要接收something
作为隐式参数:
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
}