kurrik / twittergo

Twitter client library for go
Apache License 2.0
200 stars 31 forks source link

twittergp despm returns empty 403 bodies sometimes #8

Closed jmhodges closed 9 years ago

jmhodges commented 9 years ago

Which causes very confusing errors in resp.Parse(). Specifcally, it'll return fmt.Errorf("") because of line 199 in models.go.

I haven't figured out why it's returning 403 with empty bodies (my anaconda set up worked perfectly, so this is confusing).

Two things seem to have to happen: that error message has to be improved, and the case of empty bodies on 403s has to be handled.

The error message can be marginally improved by changing that out to

err = fmt.Errorf("unable to unmarshal Twitter error object (status code %d): %v", r.StatusCode, string(b))

but it would probably be best if that was a specific type so developers can handle it better.

kurrik commented 9 years ago

Hi Jeff, thanks for reporting the issue. Makes a lot of sense, so I've updated the error responses from the Parse call.

jmhodges commented 9 years ago

Thanks! Sorry for the duplicate! My chrome got a little wacky when making them.

kurrik commented 9 years ago

No worries at all. Let me know if you have any other suggestions as you use the library - it's been a while since I've needed it for anything but I do want to keep maintaining it