Class: Toys::ArgParser::UsageError
- Inherits:
-
Object
- Object
- 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 functions similarly to an exception, but is not raised. Rather, it is returned in the #errors array.
Direct Known Subclasses
ArgMissingError, ArgValueUnacceptableError, ExtraArgumentsError, FlagAmbiguousError, FlagGroupConstraintError, FlagUnrecognizedError, FlagValueMissingError, FlagValueNotAllowedError, FlagValueUnacceptableError, ToolUnrecognizedError
Instance Attribute Summary collapse
-
#message ⇒ String
readonly
The basic error message.
-
#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
-
#full_message ⇒ String
(also: #to_s)
A fully formatted error message including suggestions.
-
#initialize(message, name: nil, value: nil, suggestions: nil) ⇒ UsageError
constructor
Create a UsageError given a message and common data.
Constructor Details
#initialize(message, name: nil, value: nil, suggestions: nil) ⇒ UsageError
Create a UsageError given a message and common data
32 33 34 |
# File 'core-docs/toys/arg_parser.rb', line 32 def initialize(, name: nil, value: nil, suggestions: nil) # Source available in the toys-core gem end |
Instance Attribute Details
#message ⇒ String (readonly)
The basic error message. Does not include suggestions, if any.
41 42 43 |
# File 'core-docs/toys/arg_parser.rb', line 41 def @message end |
#name ⇒ String? (readonly)
The name of the element (normally a flag or positional argument) that reported the error.
50 51 52 |
# File 'core-docs/toys/arg_parser.rb', line 50 def name @name end |
#suggestions ⇒ Array<String>? (readonly)
An array of suggestions from DidYouMean.
66 67 68 |
# File 'core-docs/toys/arg_parser.rb', line 66 def suggestions @suggestions end |
#value ⇒ String? (readonly)
The value that was rejected.
58 59 60 |
# File 'core-docs/toys/arg_parser.rb', line 58 def value @value end |
Instance Method Details
#full_message ⇒ String Also known as: to_s
A fully formatted error message including suggestions.
73 74 75 |
# File 'core-docs/toys/arg_parser.rb', line 73 def # Source available in the toys-core gem end |