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



23
24
25
26
27
28
# File 'lib/sevgi/executor/error.rb', line 23

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

  super(error.message)
end

Instance Attribute Details

#errorException (readonly)

Returns the original script exception.

Returns:

  • (Exception)


13
14
15
# File 'lib/sevgi/executor/error.rb', line 13

def error
  @error
end

#scopeSevgi::Executor::Scope (readonly)

Returns the executor scope active when the error was captured.

Returns:

  • (Sevgi::Executor::Scope)


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

def scope
  @scope
end

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



32
33
34
35
36
37
38
39
# File 'lib/sevgi/executor/error.rb', line 32

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

#causeException

Returns the original exception as the wrapped cause.

Returns:

  • (Exception)


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

def cause = error

#stackArray<String>

Returns the script load stack active at failure time.

Returns:

  • (Array<String>)

    script file names in load order



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

def stack = scope.stack