Exception: HaasbotRuby::RequestError

Inherits:
Error
  • Object
show all
Defined in:
lib/haasbot_ruby/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ RequestError

Returns a new instance of RequestError.



8
9
10
# File 'lib/haasbot_ruby/error.rb', line 8

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

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/haasbot_ruby/error.rb', line 6

def response
  @response
end

Class Method Details

.error_from_code(code) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/haasbot_ruby/error.rb', line 12

def self.error_from_code(code)
  case code.to_i
  when 1001
    InvalidRequest
  when 1002
    InvalidSignature
  when 1003
    InvalidBotGuid
  when 1004
    InvalidBotElementGuid
  when 1005
    InvalidAccountGuid
  when 1006
    InvalidMarket
  when 1007
    InvalidEnum
  when 1008
    InvalidParameter
  when 1020
    PriceSourceNotActive
  when 1021
    PriceMarketIsSyncing
  when 1022
    MissingParameter
  when 2000
    UnknownError
  else
    UnknownError
  end
end

Instance Method Details

#error_codeObject



43
44
45
# File 'lib/haasbot_ruby/error.rb', line 43

def error_code
  response['ErrorCode']
end