Exception: CSVPlusPlus::Language::SyntaxError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/csv_plus_plus/language/syntax_error.rb

Overview

An error that can be thrown for various syntax errors

Instance Method Summary collapse

Constructor Details

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

initialize



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

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

  super(message)
end

Instance Method Details

#to_sObject

to_s



19
20
21
# File 'lib/csv_plus_plus/language/syntax_error.rb', line 19

def to_s
  to_trace
end

#to_traceObject

Output a user-helpful string that references the runtime state



31
32
33
# File 'lib/csv_plus_plus/language/syntax_error.rb', line 31

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

#to_verbose_traceObject

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



24
25
26
27
28
# File 'lib/csv_plus_plus/language/syntax_error.rb', line 24

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