class VkontakteApi::Error
An exception raised by `VkontakteApi::Result` when given a response with an error.
Attributes
captcha_img[R]
Captcha image URL (only for “Captcha needed” errors). @return [String]
captcha_sid[R]
Captcha identifier (only for “Captcha needed” errors). @return [String]
error_code[R]
An error code. @return [Fixnum]
redirect_uri[R]
Redirect URL (only for 17 errors). @return [String]
Public Class Methods
new(data)
click to toggle source
An exception is initialized by the data from response mash. @param [Hash] data Error
data.
# File lib/vkontakte_api/error.rb, line 22 def initialize(data) @error_code = data.error_code @error_msg = data.error_msg request_params = parse_params(data.request_params) @method_name = request_params.delete('method') @access_token = request_params.delete('access_token') @oauth = request_params.delete('oauth') @params = request_params @captcha_sid = data.captcha_sid @captcha_img = data.captcha_img @redirect_uri = data.redirect_uri end
Public Instance Methods
message()
click to toggle source
A full description of the error. @return [String]
# File lib/vkontakte_api/error.rb, line 40 def message message = "VKontakte returned an error #{@error_code}: '#{@error_msg}'" message << " after calling method '#{@method_name}'" if @params.empty? message << " without parameters." else message << " with parameters #{@params.inspect}." end message end
Private Instance Methods
parse_params(params)
click to toggle source
# File lib/vkontakte_api/error.rb, line 54 def parse_params(params) params.inject({}) do |memo, pair| memo[pair[:key]] = pair[:value] memo end end