lib/lastfm.rb in lastfm-1.0.1 vs lib/lastfm.rb in lastfm-1.1.0

- old
+ new

@@ -21,12 +21,19 @@ base_uri API_ROOT attr_accessor :session class Error < StandardError; end - class ApiError < Error; end + class ApiError < Error + attr_reader :code + def initialize(message, code = nil) + super(message) + @code = code + end + end + def initialize(api_key, api_secret) @api_key = api_key @api_secret = api_secret end @@ -74,10 +81,10 @@ params.update(:sk => @session) if with_session params.update(:api_sig => Digest::MD5.hexdigest(build_method_signature(params))) if with_signature response = Response.new(self.class.send(http_method, '/', (http_method == :post ? :body : :query) => params).body) unless response.success? - raise ApiError.new(response.message) + raise ApiError.new(response.message, response.error) end response end