I see several issues here:

 * Entity stream failures don't go through the routing layer exception 
handling code. It also wouldn't make any sense because we are already 
sending out the response here and we cannot change the response at that 
time any more. We should document that somewhere.
 * In this particular case, however, the error could have been reported 
earlier, i.e. either before or at materialization time. There should be 
some FilePublisher constructor which immediately reports the error.
 * It would be nice if exceptions happening during materialization could be 
handled by the routing infrastructure. Not sure though how to implement 
this because stream construction and materialization are currently done at 
quite different places.

Johannes


On Saturday, January 16, 2016 at 12:17:15 AM UTC+1, Konrad Malawski wrote:
>
> Oh wait you should check 
> http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/http/directives/file-and-resource-directives/getFromFile.html
>
> I'm already in bed though ;)
> On Jan 16, 2016 00:01, "Konrad Malawski" <[email protected] 
> <javascript:>> wrote:
>
>> This may be a bug, I'll look into it soon so thanks for reporting!
>> Glad you liked the talk :-)
>>
>> -- 
>> Cheers,
>> Konrad 'ktoso’ Malawski
>> Akka <http://akka.io> @ Typesafe <http://typesafe.com>
>>
>> On 15 January 2016 at 23:57:01, Gustavo Politano ([email protected] 
>> <javascript:>) wrote:
>>
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>

-- 
>>>>>>>>>>      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.

Reply via email to