Exception: Ace::Support::Cli::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Ace::Support::Cli::Error
- Defined in:
- lib/ace/support/cli/error.rb
Overview
Exception raised to signal non-zero exit code from CLI commands.
This exception is used in the exception-based exit code pattern defined in ADR-023. Commands raise this error on failure, and the exe wrapper catches it and exits with the specified code.
Instance Attribute Summary collapse
-
#exit_code ⇒ Integer
readonly
Exit code to return when this exception is caught.
-
#original_message ⇒ String
readonly
Original error message without prefix.
Instance Method Summary collapse
-
#initialize(message, exit_code: 1) ⇒ Error
constructor
Initialize a new CLI error.
-
#message ⇒ String
Return the original message without prefix.
-
#to_s ⇒ String
Prepend “Error: ” to message for consistent user-facing output.
Constructor Details
#initialize(message, exit_code: 1) ⇒ Error
Initialize a new CLI error
49 50 51 52 53 |
# File 'lib/ace/support/cli/error.rb', line 49 def initialize(, exit_code: 1) @original_message = super() @exit_code = exit_code end |
Instance Attribute Details
#exit_code ⇒ Integer (readonly)
Exit code to return when this exception is caught
39 40 41 |
# File 'lib/ace/support/cli/error.rb', line 39 def exit_code @exit_code end |
#original_message ⇒ String (readonly)
Original error message without prefix
43 44 45 |
# File 'lib/ace/support/cli/error.rb', line 43 def @original_message end |
Instance Method Details
#message ⇒ String
Return the original message without prefix. This ensures .message returns what was passed to the constructor.
58 59 60 |
# File 'lib/ace/support/cli/error.rb', line 58 def @original_message end |
#to_s ⇒ String
Prepend “Error: ” to message for consistent user-facing output. exe wrappers use warn e.to_s which calls this method.
65 66 67 |
# File 'lib/ace/support/cli/error.rb', line 65 def to_s "Error: #{@original_message}" end |