Why is the exception in
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
object TestExceptionHandling {
d
I had a different issue with Akka Streams swallowing my exceptions. I'll post it here since this is the top Google result.
In a case like this, where source
is a Source[ByteString, Any]
:
source.runWith(StreamConverters.fromOutputStream(() => outputStream))
This returns a Future[IOResult]. If the write to the output stream fails (for example, the source fails), then the Future will still return a Success. In this case, you actually have to check the IOResult for the error:
source.runWith(StreamConverters.fromOutputStream(() => output)).
map(ior => {
if (!ior.wasSuccessful)
throw new RuntimeException(ior.getError)
})
The result of this will be a failed Future with the correct exception.