Module: Apish::Error

Defined in:
lib/apish/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/apish/error.rb', line 3

def message
  @message
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/apish/error.rb', line 3

def type
  @type
end

Instance Method Details

#initialize(message_or_error) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/apish/error.rb', line 5

def initialize( message_or_error )
  if message_or_error.is_a?( Exception )
    @message = message_or_error.message
    @type = message_or_error.class.name
  else
    @message = message_or_error
    @type = 'Exception'
  end
end

#to_jsonObject



15
16
17
# File 'lib/apish/error.rb', line 15

def to_json
  { root => body }.to_json
end

#to_xmlObject



19
20
21
# File 'lib/apish/error.rb', line 19

def to_xml
  body.to_xml :root => root
end