【发布时间】:2019-04-23 03:46:11
【问题描述】:
我想抛出如下异常:
Source.empty
.map {
throw new RuntimeException("Failed")
}
.runWith(Sink.foreach(println))
.onComplete {
case Success(_) =>
println()
case Failure(e) =>
println(s"Thrown ${e.getMessage}")
}
但是onComplete方法中没有出现异常。它打印
Exception in thread "main" java.lang.RuntimeException: Failed
at com.sweetsoft.App$.main(App.scala:30)
at com.sweetsoft.App.main(App.scala)
如何抛出异常,使流停止并出现在最后?
【问题讨论】:
标签: scala akka akka-stream