Exception: Vkontakte::API::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/vkontakte/api_error.rb

Overview

An exception raised by ‘Vkontakte::API` when given a response with an error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name, error_code, error_msg, params) ⇒ Error

Returns a new instance of Error.



9
10
11
12
13
14
# File 'lib/vkontakte/api_error.rb', line 9

def initialize(method_name, error_code, error_msg, params)
  @method_name = method_name
  @error_code  = error_code.to_i
  @error_msg   = error_msg
  @params      = params
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



7
8
9
# File 'lib/vkontakte/api_error.rb', line 7

def error_code
  @error_code
end

#error_msgObject (readonly)

Returns the value of attribute error_msg.



7
8
9
# File 'lib/vkontakte/api_error.rb', line 7

def error_msg
  @error_msg
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



7
8
9
# File 'lib/vkontakte/api_error.rb', line 7

def method_name
  @method_name
end

#paramsObject (readonly)

Returns the value of attribute params.



7
8
9
# File 'lib/vkontakte/api_error.rb', line 7

def params
  @params
end

Instance Method Details

#messageObject

A full description of the error



17
18
19
# File 'lib/vkontakte/api_error.rb', line 17

def message
  "VKontakte returned an error #{@error_code}: '#{@error_msg}' after calling method '#{@method_name}' with parameters #{@params.inspect}"
end