netsender.Send() doesn't return an error when netreceiver responds with "err" in the JSON
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)
-
-
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 newnetsender.Error
error
type that has aMessage
field that is populated with the "er"-keyed value if it exists. -
Ok, that's a trivial change and keeps the onus on the caller to handle errors as they see fit.
-
-
- changed status to resolved
- Log in to comment
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.