FAQ
I've been encountering the problem recently where I'm performing a list of
computations, any of which may error. Sometimes the caller function can
handle the errors (say, perform the next operation on any that didn't error
on the first one), but other times the caller script cannot do anything and
just needs to pass the fact that an error occurred back upstream. Here is
how I've been solving the problem, but is there a better way to do it?

http://play.golang.org/p/Q3ASgTsaaN


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Daniel Theophanes at Mar 5, 2014 at 8:03 pm
    I'm sure there are different ways, but what you have seems reasonable.
    It might also be reasonable to pass errors back on a channel and consume
    them in real time.

    -Daniel

    On Wednesday, March 5, 2014 11:29:46 AM UTC-8, Brendan Tracey wrote:

    I've been encountering the problem recently where I'm performing a list of
    computations, any of which may error. Sometimes the caller function can
    handle the errors (say, perform the next operation on any that didn't error
    on the first one), but other times the caller script cannot do anything and
    just needs to pass the fact that an error occurred back upstream. Here is
    how I've been solving the problem, but is there a better way to do it?

    http://play.golang.org/p/Q3ASgTsaaN

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Brendan Tracey at Mar 5, 2014 at 8:26 pm
    Thanks for the reply. I should be thinking about composing via channels
    more than I do. The waitgroup technique works pretty well, but for this
    case channels may be better. Good food for thought.
    On Wednesday, March 5, 2014 12:03:47 PM UTC-8, Daniel Theophanes wrote:

    I'm sure there are different ways, but what you have seems reasonable.
    It might also be reasonable to pass errors back on a channel and consume
    them in real time.

    -Daniel

    On Wednesday, March 5, 2014 11:29:46 AM UTC-8, Brendan Tracey wrote:

    I've been encountering the problem recently where I'm performing a list
    of computations, any of which may error. Sometimes the caller function can
    handle the errors (say, perform the next operation on any that didn't error
    on the first one), but other times the caller script cannot do anything and
    just needs to pass the fact that an error occurred back upstream. Here is
    how I've been solving the problem, but is there a better way to do it?

    http://play.golang.org/p/Q3ASgTsaaN

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 5, '14 at 7:29p
activeMar 5, '14 at 8:26p
posts3
users2
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase