Exception: MediawikiApi::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/mediawiki_api/exceptions.rb

Overview

generic MediaWiki api errors

Direct Known Subclasses

EditError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ ApiError


6
7
8
# File 'lib/mediawiki_api/exceptions.rb', line 6

def initialize(response = nil)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response


4
5
6
# File 'lib/mediawiki_api/exceptions.rb', line 4

def response
  @response
end

Instance Method Details

#codeObject


10
11
12
# File 'lib/mediawiki_api/exceptions.rb', line 10

def code
  response_data['code'] || '000'
end

#infoObject


14
15
16
# File 'lib/mediawiki_api/exceptions.rb', line 14

def info
  response_data['info'] || 'unknown API error'
end

#to_sObject


18
19
20
# File 'lib/mediawiki_api/exceptions.rb', line 18

def to_s
  "#{info} (#{code})"
end