Exception: CSVPlusPlus::Error::SyntaxError

Inherits:
Error
  • Object
show all
Defined in:
lib/csv_plus_plus/error/syntax_error.rb

Overview

An error that can be thrown for various syntax errors

Direct Known Subclasses

FormulaSyntaxError, ModifierSyntaxError

Instance Method Summary collapse

Constructor Details

#initialize(runtime, wrapped_error: nil) ⇒ SyntaxError

Returns a new instance of SyntaxError.

Parameters:

  • 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



10
11
12
13
14
15
# File 'lib/csv_plus_plus/error/syntax_error.rb', line 10

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

  super()
end

Instance Method Details

#to_sString

Returns:

  • (String)


18
19
20
# File 'lib/csv_plus_plus/error/syntax_error.rb', line 18

def to_s
  to_trace
end

#to_traceString

Output a user-helpful string that references the runtime state

Returns:

  • (String)


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

def to_trace
  "#{message_prefix}#{cell_index} #{error_message}"
end

#to_verbose_traceObject

Output a verbose user-helpful string that references the current runtime



23
24
25
26
27
# File 'lib/csv_plus_plus/error/syntax_error.rb', line 23

def to_verbose_trace
  warn(@wrapped_error.full_message) if @wrapped_error
  warn(@wrapped_error.backtrace) if @wrapped_error
  to_trace
end