Hi Jaap,
This is located here in the documentation:
Using ask will send a message to the receiving Actor as with tell, and the
receiving actor must reply withsender() ! reply in order to complete the
returned Future with a value. The ask operation involves creating an
internal actor for handling this reply, which needs to have a timeout after
which it is destroyed in order not to leak resources; see more below.
Warning
To complete the future with an exception you need send a Failure message to
the sender. This is *not done automatically* when an actor throws an
exception while processing a message.
1. try {
2. val result = operation()
3. sender() ! result
4. } catch {
5. case e: Exception =>
6. sender() ! akka.actor.Status.Failure(e)
7. throw e
8. }
http://doc.akka.io/docs/akka/2.3.5/scala/actors.html
On Thu, Sep 4, 2014 at 1:22 PM, Jaap Taal <[email protected]> wrote:
> Let's say I have an actor that interacts with an FTP server (which is done
> by blocking code from an existing FTP lib).
>
> I have code that uses '?' like this:
>
> val response:Future[Boolean] = ftpActor ? DoesFileExist("filename")
>
> What is the best way to model a general error. I've read that using try
> catch in the actor is not the best way to do it (
> http://doc.akka.io/docs/akka/snapshot/java/howto.html#Single-Use_Actor_Trees_with_High-Level_Error_Reporting
> ).
>
> This custom supervision described in that howto is not what I'm aiming
> for. The ftpActor works 99% of the time, but for the instances that it
> doesn't, the ftpActor doesn't notify the sender of this failure.
> Examples could be an incorrectly configured username password.
> The caller of DoesFileExist receives a timeout exception which is not
> really what's going on.
>
> So what's generally the best way to have a unhappy path with such an
> actor? I really don't want to add more actors into the equation, just to
> support the unhappy flow.
>
>
> Thanks,
> Jaap
>
> --
> >>>>>>>>>> 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 http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
--
Cheers,
√
--
>>>>>>>>>> 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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.