Exception: JsChat::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/jschat/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(code_key, message) ⇒ Error

Returns a new instance of Error.



3
4
5
6
# File 'lib/jschat/errors.rb', line 3

def initialize(code_key, message)
  @message = message
  @code = JsChat::Errors::Codes.invert[code_key]
end

Instance Method Details

#to_json(*a) ⇒ Object

Note: This shouldn’t really include ‘display’ directives



9
10
11
# File 'lib/jschat/errors.rb', line 9

def to_json(*a)
  { 'display' => 'error', 'error' => { 'message' => @message, 'code' => @code } }.to_json(*a)
end