Module: Toolx::Core::Errors::NestedError

Included in:
AppError, NestedStandardError
Defined in:
lib/toolx/core/errors/nested_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nestedObject (readonly)

Returns the value of attribute nested.



7
8
9
# File 'lib/toolx/core/errors/nested_error.rb', line 7

def nested
  @nested
end

#raw_backtraceObject (readonly)

Returns the value of attribute raw_backtrace.



7
8
9
# File 'lib/toolx/core/errors/nested_error.rb', line 7

def raw_backtrace
  @raw_backtrace
end

Instance Method Details

#initialize(msg = nil, nested = $ERROR_INFO) ⇒ Object



9
10
11
12
# File 'lib/toolx/core/errors/nested_error.rb', line 9

def initialize(msg = nil, nested = $ERROR_INFO)
  super(msg)
  @nested = nested
end

#set_backtrace(backtrace) ⇒ Object

rubocop:disable Naming/AccessorMethodName



14
15
16
17
18
19
20
21
22
# File 'lib/toolx/core/errors/nested_error.rb', line 14

def set_backtrace(backtrace) # rubocop:disable Naming/AccessorMethodName
  @raw_backtrace = backtrace
  if nested
    backtrace -= nested_raw_backtrace
    backtrace += ["#{nested.backtrace.first}: #{nested.message} (#{nested.class.name})"]
    backtrace += nested.backtrace[1..] || []
  end
  super(backtrace)
end