Exception: Yarr::InputParser::ParseError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/yarr/input_parser.rb

Overview

Error raised when parsing fails

Instance Method Summary collapse

Constructor Details

#initialize(parslet_error) ⇒ ParseError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This class should be only instantiated from within the Yarr::InputParser


85
86
87
# File 'lib/yarr/input_parser.rb', line 85

def initialize(parslet_error)
  @parslet_error = parslet_error
end

Instance Method Details

#report(message) ⇒ String

Reports the parse error occurred

Parameters:

  • message (String)

    original message of the bot

Returns:

  • (String)

    bot response


92
93
94
95
96
97
# File 'lib/yarr/input_parser.rb', line 92

def report(message)
  cause = @parslet_error.parse_failure_cause
  position = cause.pos.charpos
  puts cause.ascii_tree if Yarr.config.development?
  "parser error at position #{position} around `#{message[position]}'"
end