Exception: Walrus::Grammar::SkippedSubstringException

Inherits:
Exception
  • Object
show all
Includes:
LocationTracking
Defined in:
lib/walrus/grammar/skipped_substring_exception.rb

Overview

I don’t really like using Exceptions for non-error situations, but it seems that using throw/catch here would not be adequate (not possible to embed information in the thrown symbol).

Instance Method Summary collapse

Constructor Details

#initialize(substring, info = {}) ⇒ SkippedSubstringException

Returns a new instance of SkippedSubstringException.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/walrus/grammar/skipped_substring_exception.rb', line 19

def initialize(substring, info = {})
  super substring
  
  # TODO: this code is just like the code in ParseError. could save repeating it by setting up inheritance
  # but would need to pay careful attention to the ordering of my rescue blocks
  # and also change many instances of "kind_of" in my specs to "instance_of "
  # alternatively, could look at using a mix-in
  self.line_start     = info[:line_start]
  self.column_start   = info[:column_start]
  self.line_end       = info[:line_end]
  self.column_end     = info[:column_end]
end