Exception: Toys::ContextualError
- Inherits:
-
StandardError
- Object
- StandardError
- Toys::ContextualError
- Defined in:
- lib/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.
Instance Attribute Summary collapse
-
#banner ⇒ String
readonly
An overall banner message.
-
#tool_args ⇒ Array<String>
readonly
The arguments passed to the tool that was running when the error occurred.
-
#tool_file_line ⇒ Integer?
(also: #config_line)
readonly
The line number in the toys tool file in which the error was detected.
-
#tool_file_path ⇒ String?
(also: #config_path)
readonly
The path to the toys tool file in which the error was detected.
-
#tool_name ⇒ Array<String>
readonly
The full name of the tool that was running or being loaded when the error occurred.
-
#tool_verb ⇒ String?
readonly
The verb in progress when the error occurred.
Instance Method Summary collapse
-
#root_cause ⇒ Exception?
Returns the root cause of this error, i.e.
Instance Attribute Details
#banner ⇒ String (readonly)
An overall banner message
97 98 99 |
# File 'lib/toys/errors.rb', line 97 def @banner end |
#tool_args ⇒ Array<String> (readonly)
The arguments passed to the tool that was running when the error occurred.
140 141 142 |
# File 'lib/toys/errors.rb', line 140 def tool_args @tool_args end |
#tool_file_line ⇒ Integer? (readonly) Also known as: config_line
The line number in the toys tool file in which the error was detected.
116 117 118 |
# File 'lib/toys/errors.rb', line 116 def tool_file_line @tool_file_line end |
#tool_file_path ⇒ String? (readonly) Also known as: config_path
The path to the toys tool file in which the error was detected.
106 107 108 |
# File 'lib/toys/errors.rb', line 106 def tool_file_path @tool_file_path end |
#tool_name ⇒ Array<String> (readonly)
The full name of the tool that was running or being loaded when the error occurred.
133 134 135 |
# File 'lib/toys/errors.rb', line 133 def tool_name @tool_name end |
#tool_verb ⇒ String? (readonly)
The verb in progress when the error occurred.
125 126 127 |
# File 'lib/toys/errors.rb', line 125 def tool_verb @tool_verb end |
Instance Method Details
#root_cause ⇒ Exception?
Returns the root cause of this error, i.e. the first cause in the chain that is not itself a ContextualError.
150 151 152 153 154 155 156 |
# File 'lib/toys/errors.rb', line 150 def root_cause current = cause while current.is_a?(ContextualError) current = current.cause end current end |