Exception: ZSS::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/zss/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code = 500, developer_message = nil, payload: nil) ⇒ Error

Returns a new instance of Error.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zss/error.rb', line 9

def initialize(code = 500, developer_message = nil, payload: nil)

  if payload
    fail "Invalid error code: #{code}" if code.blank?
  else
    data = self.class.get_errors[code.to_s]
    payload = data.body if data
  end

  fail "Invalid error with code: #{code}" unless payload

  @code = code.to_i
  @developer_message = developer_message || payload.developerMessage
  @user_message = payload.userMessage
  super @developer_message
  set_backtrace caller
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#developer_messageObject

Returns the value of attribute developer_message.



7
8
9
# File 'lib/zss/error.rb', line 7

def developer_message
  @developer_message
end

#user_messageObject (readonly)

Returns the value of attribute user_message.



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

def user_message
  @user_message
end

Class Method Details

.[](code) ⇒ Object



27
28
29
30
# File 'lib/zss/error.rb', line 27

def self.[](code)
  data = get_errors[code.to_s]
  Error.new(code.to_i, data.body)
end