Burgestrand / spotify

Low-level Ruby bindings for libspotify, the official Spotify C API
https://rubygems.org/gems/spotify
Other
147 stars 17 forks source link

Add #code and #symbol methods to Spotify::Error #25

Closed jtomaszewski closed 10 years ago

jtomaszewski commented 10 years ago

Hey,

I thought that it would be great if I could just get symbol of the spotify error like Spotify::Error.new(:ok).code and Spotify::Error.new(:ok).symbol, instead of toying with RegExping the error's message.

Burgestrand commented 10 years ago

Looks good to me. Thank you!

@jtomaszewski even if it makes sense to have this data readily available, I’m curious; what is your use-case?

jtomaszewski commented 10 years ago

Thanks for the quick merging!

My usecase? I'm synchronizing user's account with Spotify in my web application and I wanted to distinguish the :bad_username_or_password error from :user_needs_premium. This is where the error.code == ? is useful =)