sfreiberg / gotwilio

Twilio library for Go (golang).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

non-idiomatic Go returning 2 error types

kmanley opened this issue · comments

I just took a first look at this package but was immediately confused by the fact that methods like SendSMS return two different kinds of error info: *Exception and error. What are the semantics of a function that returns 2 different error types? It would be more idiomatic to return just (data, error) and include any exception data inside the error.

Hi Kevin,

The code base is just a couple of weeks shy of 8 years old. There are probably quite a few things that are not idiomatic. Regardless I don't feel that breaking backwards compatibility is worth the trade off of being more idiomatic. I think it's pretty clear that the actual error means something happened between the application and talking to Twilio and the Exception error means twilio didn't like the request. Of course this could be wrapped in a response struct again I think the cost of breaking years of compatibility is not worth the very small benefit.

  • Sam