Exception: CSVPlusPlus::Error::FormulaSyntaxError

Inherits:
SyntaxError show all
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

Instance Method Summary collapse

Methods inherited from SyntaxError

#to_s, #to_trace, #to_verbose_trace

Constructor Details

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

You must supply either a choices or message

Parameters:

  • message (String)

    A relevant message to show

  • bad_input (String)

    The offending input that caused the error to be thrown

  • runtime (Runtime)

    The current runtime

  • 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
26
27
# File 'lib/csv_plus_plus/error/formula_syntax_error.rb', line 22

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

  super(runtime, wrapped_error:)
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



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

def bad_input
  @bad_input
end

#message::String (readonly)

A helpful error message

Returns:

  • (::String)

    the current value of message



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

def message
  @message
end

Instance Method Details

#error_message::String

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

Returns:

  • (::String)


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

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