Commits

Carl Friedrich Bolz committed 2f78475

proper error handling

  • Participants
  • Parent commits 7d59feb

Comments (0)

Files changed (2)

File prolog/interpreter/parsing.py

 from rpython.rlib.parsing.deterministic import DFA
 from rpython.rlib.parsing.tree import Nonterminal, Symbol, RPythonVisitor
 from rpython.rlib.parsing.parsing import PackratParser, LazyParseTable, Rule
-from rpython.rlib.parsing.parsing import ParseError
+from rpython.rlib.parsing.parsing import ParseError, ErrorInformation
 from rpython.rlib.parsing.regex import StringExpression
 from pypy.objspace.std.strutil import string_to_int, ParseStringOverflowError, ParseStringError
 from rpython.rlib.rarithmetic import ovfcheck
             lines.append(line)
             line = []
     if line:
-        raise ParseError(tokens[-1].source_pos, "expected '.'")
+        pos = tokens[-1].source_pos
+        raise ParseError(pos, ErrorInformation(pos, ["."]))
     if parser is None:
         parser = parser_fact
     trees = []

File prolog/interpreter/test/test_parsing.py

 def test_missing_dot():
     with py.test.raises(ParseError):
         parse_file("g. f(x)")
+    info = py.test.raises(ParseError, parse_file, "g. f(X)")
+    assert "ParseError: expected ." in info.value.nice_error_message()