Exception: CSVPlusPlus::Error::FormulaSyntaxError

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

Overview

An error that can be thrown when there is an error parsing a modifier

Instance Attribute Summary collapse

Attributes inherited from Error

#wrapped_error

Instance Method Summary collapse

Constructor Details

#initialize(message, bad_input:, wrapped_error: nil) ⇒ FormulaSyntaxError

Returns a new instance of FormulaSyntaxError.

Parameters:

  • message (String)

    A relevant message to show

  • bad_input (String)

    The offending input that caused the error to be thrown

  • wrapped_error (StandardError) (defaults to: nil)

    The underlying error that caused the syntax error. For example a Racc::ParseError that was thrown



22
23
24
25
# File 'lib/csv_plus_plus/error/formula_syntax_error.rb', line 22

def initialize(message, bad_input:, wrapped_error: nil)
  super(message, wrapped_error:)
  @bad_input = bad_input
end

Instance Attribute Details

#bad_inputString (readonly)

The offending input that caused the error to be thrown

Returns:

  • (String)

    the current value of bad_input



10
11
12
# File 'lib/csv_plus_plus/error/formula_syntax_error.rb', line 10

def bad_input
  @bad_input
end

#message::String (readonly)

A helpful error message

Returns:

  • (::String)

    the current value of message



10
11
12
# File 'lib/csv_plus_plus/error/formula_syntax_error.rb', line 10

def message
  @message
end

Instance Method Details

#error_message::String

Create a relevant error message given @bad_input and @message.

Returns:

  • (::String)


31
32
33
# File 'lib/csv_plus_plus/error/formula_syntax_error.rb', line 31

def error_message
  "#{message}: \"#{bad_input}\""
end