FAQ
I'm confused about when it's best to handle errors right away and when we
should propagate the error. If error propagation is preferred, does it mean
that we should always define method with return values like (response,
error)? And inside the function, we do something like:

if err := someFunctionCall(); err != nil {
   return nil, err
}


A more concrete example: I need to create method A that calls B, and inside
B, it uses some HTTP API. should I propagate those http errors to A or just
return nil from B and check if the return value is nil in A.

--
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/d/optout.

Search Discussions

  • Tamás Gulácsi at Mar 31, 2016 at 4:25 am
    If you can handle it(either by doing something, or ignoring some kind of error, or retrying), then handle it.
    If you can't, then propagate it.
    Maybe augment it with stg like errgo.Noted (from gopkg.in/errgo.v1).

    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 30, '16 at 11:33p
activeMar 31, '16 at 4:25a
posts2
users2
websitegolang.org

2 users in discussion

Hang: 1 post Tamás Gulácsi: 1 post

People

Translate

site design / logo © 2021 Grokbase