Exception: CSVPlusPlus::Error::ModifierSyntaxError

Inherits:
Error
  • Object
show all
Extended by:
T::Sig
Includes:
PositionalError
Defined in:
lib/csv_plus_plus/error/modifier_syntax_error.rb

Overview

A syntax error encountered when parsing a modifier definition

Direct Known Subclasses

ModifierValidationError

Instance Attribute Summary collapse

Attributes inherited from Error

#wrapped_error

Instance Method Summary collapse

Constructor Details

#initialize(message, bad_input:, modifier: nil, wrapped_error: nil) ⇒ ModifierSyntaxError

Returns a new instance of ModifierSyntaxError.

Parameters:

  • message (String)

    The error message

  • bad_input (String)

    The offending input

  • modifier (Symbol) (defaults to: nil)

    The modifier being parsed

  • wrapped_error (ModifierValidationError) (defaults to: nil)

    The validtion error that this is wrapping



29
30
31
32
33
34
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 29

def initialize(message, bad_input:, modifier: nil, wrapped_error: nil)
  super(message, wrapped_error:)

  @bad_input = bad_input
  @modifier = modifier
end

Instance Attribute Details

#bad_inputObject (readonly)

Returns the value of attribute bad_input.



12
13
14
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 12

def bad_input
  @bad_input
end

#modifierObject (readonly)

Returns the value of attribute modifier.



15
16
17
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 15

def modifier
  @modifier
end

Instance Method Details

#error_message::String

Create a relevant error message given @choices or @message (one of them must be supplied).

Returns:

  • (::String)


40
41
42
43
44
45
46
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 40

def error_message
  <<~ERROR_MESSAGE
    Error parsing modifier: [[#{@modifier}=...]]
    Bad input: #{@bad_input}
    Reason: #{@message}
  ERROR_MESSAGE
end