Exception: Sumi::Executor::Error

Inherits:
Sumi::Error
  • Object
show all
Defined in:
toplevel/lib/sumi/executor/error.rb

Overview

Wraps an exception raised while executing Sumi script source. Its visited source snapshot records every source in load order. It is not the active load stack at the instant of failure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Sumi::Error

call

Constructor Details

#initialize(error, stack) ⇒ void

Builds an executor error wrapper.

Parameters:

  • error (Exception) —

    original exception

  • stack (Array<String>) —

    source file keys visited in load order. The Array and its String entries are copied and frozen



27
28
29
30
31
32
# File 'toplevel/lib/sumi/executor/error.rb', line 27

def initialize(error, stack)
  @cause = error
  @stack = stack.map { it.dup.freeze }.freeze

  super(error.message)
end

Instance Attribute Details

#cause ⇒ Exception (readonly)

Returns the original exception as the wrapped cause.

Returns:

  • (Exception)


47
48
49
# File 'toplevel/lib/sumi/executor/error.rb', line 47

def cause
  @cause
end

Instance Method Details

#load_backtrace ⇒ Array<String>

Returns backtrace entries that belong to the visited Sumi source set.

Returns:

  • (Array<String>) —

    filtered backtrace lines relative to the current directory, or an empty Array when the original exception has no backtrace



37
38
39
40
41
42
43
# File 'toplevel/lib/sumi/executor/error.rb', line 37

def load_backtrace
  sources = @stack.map { ::File.expand_path(it) }

  Array(cause.backtrace)
    .select { sources.include?(::File.expand_path(it.split(":", 2).first)) }
    .map { |line| line.delete_prefix("#{::Dir.pwd}/") }
end