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.



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

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#infoObject (readonly)

Returns the value of attribute info.



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

def info
  @info
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

Instance Method Details

#to_sObject



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

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