Exception: CSVPlusPlus::Error::ModifierValidationError
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/error/modifier_validation_error.rb
Overview
An error that can be thrown when a modifier doesn’t pass our validation.
Instance Attribute Summary collapse
-
#bad_input ⇒ String
readonly
The offending input that caused the error to be thrown.
-
#choices ⇒ Array<Symbol>?
readonly
The choices that
valuemust be one of (but violated). -
#message ⇒ String?
readonly
A relevant message to show.
-
#modifier ⇒ Symbol
readonly
The modifier being parsed when the bad input was encountered.
Instance Method Summary collapse
-
#error_message ⇒ ::String
A user-facing error message.
-
#initialize(modifier, bad_input:, choices: nil, message: nil) ⇒ ModifierValidationError
constructor
You must supply either a
choicesormessage.
Constructor Details
#initialize(modifier, bad_input:, choices: nil, message: nil) ⇒ ModifierValidationError
You must supply either a choices or message
rubocop:disable Metrics/MethodLength
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/csv_plus_plus/error/modifier_validation_error.rb', line 42 def initialize(modifier, bad_input:, choices: nil, message: nil) @bad_input = bad_input @choices = choices @modifier = modifier @message = ::T.let( if @choices "must be one of (#{@choices.values.map(&:serialize).join(', ')})" else ::T.must() end, ::String ) super(@message) end |
Instance Attribute Details
#bad_input ⇒ String (readonly)
The offending input that caused the error to be thrown
12 13 14 |
# File 'lib/csv_plus_plus/error/modifier_validation_error.rb', line 12 def bad_input @bad_input end |
#choices ⇒ Array<Symbol>? (readonly)
The choices that value must be one of (but violated)
12 13 14 |
# File 'lib/csv_plus_plus/error/modifier_validation_error.rb', line 12 def choices @choices end |
#message ⇒ String? (readonly)
A relevant message to show
12 13 14 |
# File 'lib/csv_plus_plus/error/modifier_validation_error.rb', line 12 def @message end |
#modifier ⇒ Symbol (readonly)
The modifier being parsed when the bad input was encountered
12 13 14 |
# File 'lib/csv_plus_plus/error/modifier_validation_error.rb', line 12 def modifier @modifier end |
Instance Method Details
#error_message ⇒ ::String
A user-facing error message
64 65 66 |
# File 'lib/csv_plus_plus/error/modifier_validation_error.rb', line 64 def @message end |