Exception: Whittle::ParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/whittle/errors/parse_error.rb

Overview

ParseError is raised if the parse encounters an unexpected token in the input.

You can extract the line number, the expected input and the received input.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, line, expected, received) ⇒ ParseError

Initialize the ParseError with information about the location

Parameters:

  • message (String)

    the exception message displayed to the user

  • line (Fixnum)

    the line on which the unexpected token was encountered

  • expected (Array)

    an array of all possible tokens in the current parser state

  • received (String, Symbol)

    the name of the actually received token



27
28
29
30
31
32
33
# File 'lib/whittle/errors/parse_error.rb', line 27

def initialize(message, line, expected, received)
  super(message)

  @line     = line
  @expected = expected
  @received = received
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



11
12
13
# File 'lib/whittle/errors/parse_error.rb', line 11

def expected
  @expected
end

#lineObject (readonly)

Returns the value of attribute line.



10
11
12
# File 'lib/whittle/errors/parse_error.rb', line 10

def line
  @line
end

#receivedObject (readonly)

Returns the value of attribute received.



12
13
14
# File 'lib/whittle/errors/parse_error.rb', line 12

def received
  @received
end