Sha256: 0c3c826bbc7f5a13a13cec975fe9c6753e15cca9350fe044f6ad9f6f8552fa2a

Contents?: true

Size: 674 Bytes

Versions: 34

Compression:

Stored size: 674 Bytes

Contents

module Flickr
    class Error < RuntimeError
      attr_accessor :code
    end
    
    
    class Errors
      
      # Method used for raising the appropriate error class for a given error code.
      # Currently raises only Flickr::Error
      def self.error_for(code, message)
        raise RuntimeError.new("Internal error. Flickr API error not identified or unknown error.") if (code.nil? || message.nil? || message.empty?)
        raise RuntimeError.new("Internal error. Unknown error.") if code.to_i == 0 # We assume that error code 0 is never returned
        e = Flickr::Error.new("#{code}: #{message}")
        e.code = code
        raise e
      end
    end

end

Version data entries

34 entries across 34 versions & 11 rubygems

Version Path
flickr_fu-0.3.4 lib/flickr/errors.rb
flickr_fu-0.3.3 lib/flickr/errors.rb
ayn-flickr_fu-0.3.5 lib/flickr/errors.rb
ayn-flickr_fu-0.3.6 lib/flickr/errors.rb
ayn-flickr_fu-0.3.7 lib/flickr/errors.rb
ayn-flickr_fu-0.3.9 lib/flickr/errors.rb
commonthread-flickr_fu-0.2.0 lib/flickr/errors.rb
commonthread-flickr_fu-0.2.1 lib/flickr/errors.rb
commonthread-flickr_fu-0.2.2 lib/flickr/errors.rb
commonthread-flickr_fu-0.3.0 lib/flickr/errors.rb
maciej-flickr_fu-0.3.0 lib/flickr/errors.rb
rmm5t-flickr_fu-0.3.1 lib/flickr/errors.rb
rschenk-flickr_fu-0.3.2 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.8 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.7 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.6 lib/flickr/errors.rb
flickr_fu-0.3.2 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.4 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.3 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.2 lib/flickr/errors.rb