Hi!
I was watching Konrad's workshop from Scala eXchange - amazing talk, btw -
(https://skillsmatter.com/skillscasts/6869-workshop-end-to-end-asynchronous-back-pressure-with-akka-streams)
and latter playing with the code.
On step 3 is demoed a stream completed with a file from disk. I changed the
name of the file to a inexistent one, so I could force an exception and
check the exception handling. My expectation was that the browser would
receive an HTML with the exception details, since the following handler is
used:
val myExceptionHandler = ExceptionHandler {
case ex: Exception =>
complete {
<html>
<body>
{ex.getMessage}
</body>
</html>
}
}
// our routes:
val route: Route = handleExceptions(myExceptionHandler) {
helloRoutes ~ simpleStreamRoutes
}
But what happened was that the connection was reset in Safari and it received
nothing. When I tested on Chrome, I saw that it started the download of a file
with the wrong name, but it failed with a network error as well. On the console
I could see the following:
[ERROR] [01/15/2016 13:45:06.181] [default-akka.actor.default-dispatcher-12]
[akka.actor.ActorSystemImpl(default)] Outgoing response stream error
java.io.FileNotFoundException: .data.csv (No such file or directory)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at akka.stream.impl.io.FilePublisher.preStart(FilePublisher.scala:49)
at akka.actor.Actor$class.aroundPreStart(Actor.scala:485)
at
akka.stream.impl.io.FilePublisher.akka$stream$actor$ActorPublisher$$super$aroundPreStart(FilePublisher.scala:34)
at
akka.stream.actor.ActorPublisher$class.aroundPreStart(ActorPublisher.scala:322)
at
akka.stream.impl.io.FilePublisher.aroundPreStart(FilePublisher.scala:34)
at akka.actor.ActorCell.create(ActorCell.scala:590)
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:461)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:483)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
at akka.dispatch.Mailbox.run(Mailbox.scala:223)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
So my question is if this is the excepted behavior or it's a bug of some sorts.
And, if it is the expected behavior, then I don't really understand when the
exception handling would kick in, and where I could handle exceptions like this.
Thanks,
Gus.
PS: link to the original code:
https://github.com/ktoso/akka-scala-exchange/blob/master/src/main/scala/samples/scalaexchange/step3/SimpleStreamHttpServiceApp.scala
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.