Exception: MediaWiki::APIError

Inherits:
Exception
  • Object
show all
Defined in:
lib/media_wiki/exception.rb

Overview

Wrapper for errors returned by MediaWiki API. Possible codes are defined in www.mediawiki.org/wiki/API:Errors_and_warnings.

Warnings also throw errors with code ‘warning’, unless MediaWiki::Gateway#new was called with :ignorewarnings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, info) ⇒ APIError

Returns a new instance of APIError.



12
13
14
15
16
# File 'lib/media_wiki/exception.rb', line 12

def initialize(code, info)
  @code = code
  @info = info
  @message = "API error: code '#{code}', info '#{info}'"
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



10
11
12
# File 'lib/media_wiki/exception.rb', line 10

def code
  @code
end

#infoObject (readonly)

Returns the value of attribute info.



10
11
12
# File 'lib/media_wiki/exception.rb', line 10

def info
  @info
end

#messageObject (readonly)

Returns the value of attribute message.



10
11
12
# File 'lib/media_wiki/exception.rb', line 10

def message
  @message
end

Instance Method Details

#to_sObject



18
19
20
# File 'lib/media_wiki/exception.rb', line 18

def to_s
  "#{self.class.to_s}: #{@message}"
end