Exception: Toys::ContextualError

Inherits:
StandardError
  • Object
show all
Defined in:
core-docs/toys/errors.rb

Overview

A wrapper exception used to provide user-oriented context for an error thrown during tool execution. Most exceptions raised during a tool run are wrapped with one of these (with the original exception set as the cause.)

Signals are not wrapped in this class. A SignalException raised by a tool propagates as itself, so that tools can intercept it and the Ruby VM can ultimately handle it. See the error_handler argument to Runner#initialize for how each is reported.

Defined in the toys-core gem

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

An overall banner message

Returns:

  • (String)


81
82
83
# File 'core-docs/toys/errors.rb', line 81

def banner
  @banner
end

#tool_argsArray<String> (readonly)

The arguments passed to the tool that was running when the error occurred.

Returns:

  • (Array<String>)


124
125
126
# File 'core-docs/toys/errors.rb', line 124

def tool_args
  @tool_args
end

#tool_file_lineInteger? (readonly) Also known as: config_line

The line number in the toys tool file in which the error was detected.

Returns:

  • (Integer)

    if a tool file is found in the backtrace.

  • (nil)

    if no backtrace is available or no toys tool file could be found in it.



100
101
102
# File 'core-docs/toys/errors.rb', line 100

def tool_file_line
  @tool_file_line
end

#tool_file_pathString? (readonly) Also known as: config_path

The path to the toys tool file in which the error was detected.

Returns:

  • (String)

    if a tool file is found in the backtrace.

  • (nil)

    if no backtrace is available or no toys tool file could be found in it.



90
91
92
# File 'core-docs/toys/errors.rb', line 90

def tool_file_path
  @tool_file_path
end

#tool_nameArray<String> (readonly)

The full name of the tool that was running or being loaded when the error occurred.

Returns:

  • (Array<String>)


117
118
119
# File 'core-docs/toys/errors.rb', line 117

def tool_name
  @tool_name
end

#tool_verbString? (readonly)

The verb in progress when the error occurred.

Returns:

  • (String)

    should be either "loading" or "running"

  • (nil)

    if the verb is not known



109
110
111
# File 'core-docs/toys/errors.rb', line 109

def tool_verb
  @tool_verb
end

Instance Method Details

#root_causeException?

Returns the root cause of this error, i.e. the first cause in the chain that is not itself a ContextualError.

Returns:

  • (Exception)

    The root cause.

  • (nil)

    if this error has no cause, which happens only if it was constructed outside a rescue.



134
135
136
# File 'core-docs/toys/errors.rb', line 134

def root_cause
  # Source available in the toys-core gem
end