Class: Sevgi::Executor::Error

Inherits:
Sevgi::Error
  • Object
show all
Defined in:
lib/sevgi/executor/error.rb

Overview

Wraps an exception raised while executing Sevgi script source.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, scope) ⇒ void

Builds an executor error wrapper.

Parameters:

  • error (Exception)

    original exception

  • scope (Sevgi::Executor::Scope)

    executor scope active at failure time



17
18
19
20
21
22
# File 'lib/sevgi/executor/error.rb', line 17

def initialize(error, scope)
  @error = error
  @scope = scope

  super(error.message)
end

Instance Attribute Details

#errorException (readonly)

Returns original exception raised by script execution.

Returns:

  • (Exception)

    original exception raised by script execution



11
12
13
# File 'lib/sevgi/executor/error.rb', line 11

def error
  @error
end

#scopeObject (readonly)

Returns the value of attribute scope.



11
# File 'lib/sevgi/executor/error.rb', line 11

attr_reader :error, :scope

Instance Method Details

#backtrace!Array<String>

Returns backtrace entries that belong to the Sevgi load stack.

Returns:

  • (Array<String>)

    filtered backtrace lines relative to the current directory



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

def backtrace!
  sources = stack.map { ::File.expand_path(it) }

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

#stackArray<String>

Returns the script load stack active at failure time.

Returns:

  • (Array<String>)

    script file names in load order



37
# File 'lib/sevgi/executor/error.rb', line 37

def stack = scope.stack