netsender.Send() doesn't return an error when netreceiver responds with "err" in the JSON

Issue #1 resolved
Jack Richardson created an issue

When netreciever returns an err code in the JSON, Send() does not return an error which means calling function is unaware that something may have gone wrong.

Should this be changed to return the err message from netreceiver so that the caller is aware and can handle the error as it sees fit?

Comments (5)

  1. Alan Noble

    We could, but I think we'd need to take a closer a look at all of the possible JSON "er" codes before going down that path. As it stands, the choice is deliberate. Client callers should always check the JSON response and handle as they see fit. This keeps the Send() simple.

  2. kortschak

    The current behaviour is sort of surprising in a Go context; having two channels for error checking is a risk for people not checking the second one (which is the reason this issue was filed). My suggestion would be to have Send check for "er"-keyed values and return a new netsender.Error error type that has a Message field that is populated with the "er"-keyed value if it exists.

  3. Log in to comment