Exception: VkLongpollBot::Exceptions::APIError

Inherits:
ResponseError
  • Object
show all
Defined in:
lib/vk_longpoll_bot/exceptions.rb

Overview

API error. Must have some code and description.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ APIError

Create new instance.

Parameters:

  • error (Hash)

    response hash which contains “error” key.



74
75
76
77
# File 'lib/vk_longpoll_bot/exceptions.rb', line 74

def initialize(error)
  @error = error["error"]
  super("#{code}: #{included_message}")
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



68
69
70
# File 'lib/vk_longpoll_bot/exceptions.rb', line 68

def error
  @error
end

Instance Method Details

#codeInteger

Returns:

  • (Integer)


81
82
83
# File 'lib/vk_longpoll_bot/exceptions.rb', line 81

def code
  @error["error_code"]
end

#descriptionString

Returns error description from API documentation.

Returns:

  • (String)

    error description from API documentation.



93
94
95
# File 'lib/vk_longpoll_bot/exceptions.rb', line 93

def description
  CODES[code]
end

#included_messageString

Returns attached error description.

Returns:

  • (String)

    attached error description.



87
88
89
# File 'lib/vk_longpoll_bot/exceptions.rb', line 87

def included_message
  @error["error_msg"]
end