--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Same goes for a failed Try.However, failures are always propagated along both (`map` preserves the failure etc)What do you propose would be done?
On Thu, Jan 9, 2014 at 8:38 AM, √iktor Ҡlang <viktor...@gmail.com> wrote:
Same goes for a failed Try.However, failures are always propagated along both (`map` preserves the failure etc)What do you propose would be done?I'm not so much proposing anything as simply looking for the best way handle failures in the least painful way possible.A lot of my usage involves `foreach` as a means to act on the result. The alternative is use `onComplete` instead, which is more boilerplatey.Maybe a method similar to `foreach` that would fail in some manner if the future had failed?
(BTW, I meant to refer to `onFailure`, not `failed` in the OP)
Cheers,√On Thu, Jan 9, 2014 at 3:35 PM, Nils Kilden-Pedersen <nil...@gmail.com> wrote:
--A failed Future is, by default, silently ignored unless a callback is provided to the `failed` method.Is there a good strategy to change that default, without incurring too much boilerplate? Generally, I'd like to avoid having to explicitly call `failed` every single time, because I know I'll forget in some cases.Longer term, is there any chance of Future having a non-silent default?
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
How about something like this:
def handle[A](f: Future[A]) = f.value match {
case Some(Success(a)) => ???
case Some(Failure(e)) => ???
case None => ???
}
On Thu, Jan 9, 2014 at 3:50 PM, Nils Kilden-Pedersen <nil...@gmail.com> wrote:
On Thu, Jan 9, 2014 at 8:38 AM, √iktor Ҡlang <viktor...@gmail.com> wrote:
Same goes for a failed Try.However, failures are always propagated along both (`map` preserves the failure etc)What do you propose would be done?I'm not so much proposing anything as simply looking for the best way handle failures in the least painful way possible.A lot of my usage involves `foreach` as a means to act on the result. The alternative is use `onComplete` instead, which is more boilerplatey.Maybe a method similar to `foreach` that would fail in some manner if the future had failed?What manner do you have in mind?"foreach" is executed on "another thread" when the Future completes, so there's nowhere to "fail to".Interesting to hear more ideas on this,
On Thu, Jan 9, 2014 at 9:08 AM, √iktor Ҡlang <viktor...@gmail.com> wrote:
On Thu, Jan 9, 2014 at 3:50 PM, Nils Kilden-Pedersen <nil...@gmail.com> wrote:
On Thu, Jan 9, 2014 at 8:38 AM, √iktor Ҡlang <viktor...@gmail.com> wrote:
Same goes for a failed Try.However, failures are always propagated along both (`map` preserves the failure etc)What do you propose would be done?I'm not so much proposing anything as simply looking for the best way handle failures in the least painful way possible.A lot of my usage involves `foreach` as a means to act on the result. The alternative is use `onComplete` instead, which is more boilerplatey.Maybe a method similar to `foreach` that would fail in some manner if the future had failed?What manner do you have in mind?"foreach" is executed on "another thread" when the Future completes, so there's nowhere to "fail to".Interesting to hear more ideas on this,The default for a Thread is to simply print to System.err. This is a reasonable default.
Open a ticket please
A cheap solution would be to have Future.foreach pipe failures to the implicit ExecutionContext's reportFailure method.
reportFailure is when there is no way to communicate back to the user that something went wrong, see its usage in the stdlib.
Cheers,
V
On Thu, Jan 9, 2014 at 8:38 AM, √iktor Ҡlang <viktor...@gmail.com> wrote:
Same goes for a failed Try.However, failures are always propagated along both (`map` preserves the failure etc)What do you propose would be done?I'm not so much proposing anything as simply looking for the best way handle failures in the least painful way possible.A lot of my usage involves `foreach` as a means to act on the result. The alternative is use `onComplete` instead, which is more boilerplatey.Maybe a method similar to `foreach` that would fail in some manner if the future had failed?
Isn't a method like that usually named `fold`?
Isn't a method like that usually named `fold`?
On Wed, Jan 22, 2014 at 11:34 PM, Naftoli Gugenheim <nafto...@gmail.com> wrote:
Isn't a method like that usually named `fold`?
Optiondef fold[B](ifEmpty: => B)(f: A => B): BListdef fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1Futuredef transform[S](s: (T) ⇒ S, f: (Throwable) ⇒ Throwable)(implicit executor: ExecutionContext): Future[S]
--Rex