Exception: CSVPlusPlus::Error::ModifierSyntaxError

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

Overview

An Error that wraps a ModifierValidationError with a Runtime.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SyntaxError

#to_s, #to_trace, #to_verbose_trace

Constructor Details

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

Returns a new instance of ModifierSyntaxError.

Parameters:



54
55
56
57
58
59
60
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 54

def initialize(runtime, bad_input:, message:, modifier: nil, wrapped_error: nil)
  @bad_input = bad_input
  @modifier = modifier
  @message = message

  super(runtime, wrapped_error:)
end

Instance Attribute Details

#bad_inputObject (readonly)

Returns the value of attribute bad_input.



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

def bad_input
  @bad_input
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#modifierObject (readonly)

Returns the value of attribute modifier.



19
20
21
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 19

def modifier
  @modifier
end

Class Method Details

.from_validation_error(runtime, modifier_validation_error) ⇒ ModifierSyntaxError

Create a ModifierSyntaxError given a runtime and ModifierValidationError.

Parameters:

Returns:



33
34
35
36
37
38
39
40
41
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 33

def self.from_validation_error(runtime, modifier_validation_error)
  new(
    runtime,
    modifier: modifier_validation_error.modifier,
    bad_input: modifier_validation_error.bad_input,
    message: modifier_validation_error.message,
    wrapped_error: modifier_validation_error
  )
end

Instance Method Details

#error_message::String

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

Returns:

  • (::String)


66
67
68
69
70
71
72
# File 'lib/csv_plus_plus/error/modifier_syntax_error.rb', line 66

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