Exception: ComponentEmbeddedRuby::UnexpectedTokenError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/component_embedded_ruby/unexpected_token_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected, got) ⇒ UnexpectedTokenError

Returns a new instance of UnexpectedTokenError.



7
8
9
10
# File 'lib/component_embedded_ruby/unexpected_token_error.rb', line 7

def initialize(expected, got)
  @expected = expected
  @got = got
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



5
6
7
# File 'lib/component_embedded_ruby/unexpected_token_error.rb', line 5

def expected
  @expected
end

#gotObject (readonly)

Returns the value of attribute got.



5
6
7
# File 'lib/component_embedded_ruby/unexpected_token_error.rb', line 5

def got
  @got
end

Instance Method Details

#messageObject



12
13
14
15
16
17
# File 'lib/component_embedded_ruby/unexpected_token_error.rb', line 12

def message
  <<~MESSAGE.strip
    Unexpected token at line #{got.position.line}, column #{got.position.column}
    Got `#{got.value}`#{expected_message}
  MESSAGE
end