Exception: Legate::ToolError

Inherits:
Error
  • Object
show all
Defined in:
lib/legate/errors.rb

Overview

Base class for errors raised during tool execution. Supports wrapping an original cause exception for debugging.

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, cause: nil) ⇒ ToolError

Returns a new instance of ToolError.

Parameters:

  • message (String) (defaults to: nil)

    The error message.

  • cause (Exception, nil) (defaults to: nil)

    The original exception that triggered this error.



31
32
33
34
35
# File 'lib/legate/errors.rb', line 31

def initialize(message = nil, cause: nil)
  super(message)
  @cause = cause
  set_backtrace(cause.backtrace) if cause&.backtrace
end

Instance Method Details

#causeException?

The explicit wrapped cause if one was passed, otherwise Ruby’s implicit cause (set automatically when the error is raised inside a rescue). Falling back to ‘super` means a caller that does `raise ToolError, msg` inside a rescue still surfaces the real cause instead of nil.

Returns:

  • (Exception, nil)

    The original exception that caused this error.



42
43
44
# File 'lib/legate/errors.rb', line 42

def cause
  @cause || super
end