Exception: Flickr::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/flickr/error.rb

Overview

This error is raised when there is an error in the request.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, code = nil) ⇒ ApiError

Returns a new instance of ApiError.



41
42
43
44
# File 'lib/flickr/error.rb', line 41

def initialize(message = nil, code = nil)
  super(message)
  @code = code.to_i
end

Instance Attribute Details

#codeInteger (readonly)

Flickr’s code of the error. The list possible errors and their codes is shown below every API method on http://flickr.com/services/api. For example:

- 100: There is no API key
- 105: Service currently unavailable
- ...

Examples:

begin
  Flickr.photos.get_recent
rescue Flickr::ApiError => error
  puts "There is no API key" if error.code == 100
end

Returns:

  • (Integer)


36
37
38
# File 'lib/flickr/error.rb', line 36

def code
  @code
end

Instance Method Details

#messageObject



46
47
48
# File 'lib/flickr/error.rb', line 46

def message
  "#{code}: #{super}"
end