Exception: ACE::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/ace/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, kind, details = nil, issue_code = nil) ⇒ Error

Returns a new instance of Error.



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

def initialize(msg, kind, details = nil, issue_code = nil)
  super(msg)
  @kind = kind
  @issue_code = issue_code
  @details = details || {}
  @error_code ||= 1
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



5
6
7
# File 'lib/ace/error.rb', line 5

def details
  @details
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



5
6
7
# File 'lib/ace/error.rb', line 5

def error_code
  @error_code
end

#issue_codeObject (readonly)

Returns the value of attribute issue_code.



5
6
7
# File 'lib/ace/error.rb', line 5

def issue_code
  @issue_code
end

#kindObject (readonly)

Returns the value of attribute kind.



5
6
7
# File 'lib/ace/error.rb', line 5

def kind
  @kind
end

Class Method Details

.to_h(message, kind, details = nil, issue_code = nil) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/ace/error.rb', line 27

def self.to_h(message, kind, details = nil, issue_code = nil)
  h = { 'kind' => kind,
        'msg' => message,
        'details' => details }
  h['issue_code'] = issue_code if issue_code
  h
end

Instance Method Details

#msgObject



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

def msg
  message
end

#to_hObject



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

def to_h
  Error.to_h(msg, kind, details, issue_code)
end

#to_json(opts = nil) ⇒ Object



23
24
25
# File 'lib/ace/error.rb', line 23

def to_json(opts = nil)
  to_h.to_json(opts)
end