Exception: Toys::ArgParser::UsageError
- Inherits:
-
StandardError
- Object
- StandardError
- Toys::ArgParser::UsageError
- Defined in:
- core-docs/toys/arg_parser.rb
Overview
Defined in the toys-core gem
Base representation of a usage error reported by the ArgParser.
This is normally not raised directly, but returned as an element in the #errors array. It will, however, have the normal message and backtrace attributes, along with additional fields as defined in this class, and it can be raised later if desired.
Direct Known Subclasses
ArgMissingError, ArgValueUnacceptableError, ExtraArgumentsError, FlagAmbiguousError, FlagGroupConstraintError, FlagUnrecognizedError, FlagValueMissingError, FlagValueNotAllowedError, FlagValueUnacceptableError, ToolUnrecognizedError
Instance Attribute Summary collapse
-
#message ⇒ String
readonly
The error message, not including any suggestions.
-
#name ⇒ String?
readonly
The name of the element (normally a flag or positional argument) that reported the error.
-
#suggestions ⇒ Array<String>?
readonly
An array of suggestions from DidYouMean.
-
#value ⇒ String?
readonly
The value that was rejected.
Instance Method Summary collapse
-
#initialize(message, name: nil, value: nil, suggestions: nil, skip_frames: 0) ⇒ UsageError
constructor
Create a UsageError given a message and common data.
-
#message_with_suggestions ⇒ String
(also: #to_s)
A fully formatted error message including suggestions.
Constructor Details
#initialize(message, name: nil, value: nil, suggestions: nil, skip_frames: 0) ⇒ UsageError
Create a UsageError given a message and common data
38 39 40 |
# File 'core-docs/toys/arg_parser.rb', line 38 def initialize(, name: nil, value: nil, suggestions: nil, skip_frames: 0) # Source available in the toys-core gem end |
Instance Attribute Details
#message ⇒ String (readonly)
Returns The error message, not including any suggestions.
45 46 47 |
# File 'core-docs/toys/arg_parser.rb', line 45 def @message end |
#name ⇒ String? (readonly)
The name of the element (normally a flag or positional argument) that reported the error.
54 55 56 |
# File 'core-docs/toys/arg_parser.rb', line 54 def name @name end |
#suggestions ⇒ Array<String>? (readonly)
An array of suggestions from DidYouMean.
70 71 72 |
# File 'core-docs/toys/arg_parser.rb', line 70 def suggestions @suggestions end |
#value ⇒ String? (readonly)
The value that was rejected.
62 63 64 |
# File 'core-docs/toys/arg_parser.rb', line 62 def value @value end |
Instance Method Details
#message_with_suggestions ⇒ String Also known as: to_s
A fully formatted error message including suggestions.
77 78 79 |
# File 'core-docs/toys/arg_parser.rb', line 77 def # Source available in the toys-core gem end |