升級我的斯卡拉最新版本,我得到這個錯誤後:升級到最新版本後:org.specs2.execute.Failure要求:T
type mismatch; found : org.specs2.execute.Failure required: T
我的代碼:
def shouldThrow[T <: Exception](exClazz: Class[T])(body: => Unit): T = {
try {
body
} catch {
case e: Throwable =>
if (e.getClass == exClazz) return e.asInstanceOf[T]
val failure = new Failure("Expected %s but got %s".format(exClazz, e.getClass), "", new Exception().getStackTrace.toList, org.specs2.execute.NoDetails())
val rethrown = new FailureException(failure)
rethrown.initCause(e)
throw rethrown
}
failure("Exception expected, but has not been thrown")
}
我在最後一行得到這個錯誤failure("...")
任何想法什麼是布萊恩?