sfreiberg / gotwilio

Twilio library for Go (golang).
BSD 2-Clause "Simplified" License
342 stars 136 forks source link

non-idiomatic Go returning 2 error types #76

Closed kmanley closed 4 years ago

kmanley commented 4 years ago

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.

sfreiberg commented 4 years ago

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.