Sha256: f69c640ca7c0c3b91d76aab3e99fcb5f25e0be2235e886e5e139185502aa16e3

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 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: #{code.inspect}") 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

4 entries across 4 versions & 1 rubygems

Version Path
fotonauts-flickr_fu-0.3.13 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.11 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.10 lib/flickr/errors.rb
fotonauts-flickr_fu-0.3.9 lib/flickr/errors.rb