birarda / logan

ruby gem to communicate with new Basecamp API
MIT License
16 stars 19 forks source link

Add some error handling #12

Closed janika closed 10 years ago

janika commented 10 years ago

Currently when requesting data (i.e. people) with Logan and using bogus/invalid authentication data, I get

Would like to get some unified answer from Logan in both cases, which would indicate that the authorization went wrong.

birarda commented 10 years ago

Hey @janika - thanks for posting this. Definitely need some better error handling on all fronts in logan. Can you give me an example of what you'd be expecting back?

This is my only ruby gem, so I'm not exactly sure what convention dictates for a method that should return an active client but actually has one that couldn't auth.

janika commented 10 years ago

@birarda I'm not sure either what is the convention:) I thought about forking and doing a pull request with something I had in mind, but I thought maybe you have something else in mind.

What I have done in my gem is raising a custom error, which is a subclass of StandardError. One example is here: https://github.com/Teamweek/teamweek-ruby/tree/master/lib/teamweek/api/response

Something similar is done in oauth2 library here: https://github.com/intridea/oauth2/blob/master/lib/oauth2/error.rb

And in instagram-ruby-gem: https://github.com/Instagram/instagram-ruby-gem

It would be good if the error can be turned into json easily. If what I have done in https://github.com/Teamweek/teamweek-ruby seems good to you I could implement in here too. Anyway, I have been keeping it very similar to logan :)

janika commented 10 years ago

Added pull request https://github.com/birarda/logan/pull/13