digitalocean / droplet_kit

DropletKit is the official DigitalOcean API client for Ruby.
MIT License
514 stars 152 forks source link

paginated_resource raises error with no api key set #59

Open imogenkinsman opened 9 years ago

imogenkinsman commented 9 years ago
client = DropletKit::Client.new(access_token: nil)
client.droplets.all.each do |droplet|
  puts droplet.name
end
=> TypeError: no implicit conversion of String into Array
from /Users/jadems/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/droplet_kit-1.2.3/lib/droplet_kit/paginated_resource.rb:68:in `retrieve'
from /Users/jadems/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/droplet_kit-1.2.3/lib/droplet_kit/paginated_resource.rb:60:in `fetch_next_page'
from /Users/jadems/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/droplet_kit-1.2.3/lib/droplet_kit/paginated_resource.rb:26:in `each'

I had a misconfigured environment and spent a few minutes trying to figure out why I was getting this. It might be helpful to handle authentication errors more gracefully.

phillbaker commented 9 years ago

Thanks for opening an issue @jademcgough! We'll get this on the list of things to look at.

techrah commented 9 years ago

I was just wondering myself how to gracefully handle such errors. Looking forward to a solution. Thanks!