This commit is contained in:
Maximilien Rigaut 2022-06-01 00:59:45 +02:00
parent c13e1524e3
commit 9b8e8886bf
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
3 changed files with 13 additions and 6 deletions

View File

@ -156,8 +156,11 @@ class MismatchedContainerError(BootstraparseError):
"""
def __init__(self, token): # FUTURE : Add file name to error
self.token = token
self.line = token.line_number
super().__init__(f"Could not process {token.label} at line {token.line_number}.")
if token:
self.line = token.line_number
else:
self.line = None
super().__init__(f"Could not process {token.label} at line {self.line}.")
class LonelyOptionalError(BootstraparseError):
@ -166,9 +169,13 @@ class LonelyOptionalError(BootstraparseError):
"""
def __init__(self, token, last_in_pile):
self.token = token
if token:
self.line = token.line_number
else:
self.line = None
if last_in_pile:
super().__init__(f"Could not match token {token} at line {token.line_number} with "
super().__init__(f"Could not match token {token} at line {self.line} with "
f"last element in pile {last_in_pile} at line {last_in_pile.line_number} (not a container).")
else:
super().__init__(f"Could not match token {token} at line {token.line_number} "
super().__init__(f"Could not match token {token} at line {self.line} "
f"as there was nothing in the pile.")

View File

@ -8,6 +8,7 @@
# import rich
import rich
from io import StringIO
from bootstraparse.modules import config, pathresolver, error_mngr, context_mngr
from collections import namedtuple
@ -244,7 +245,6 @@ class ContextConverter:
if __name__ == '__main__': # pragma: no cover
from bootstraparse.modules import parser
from io import StringIO
io_string = StringIO(
"""<<section

View File

@ -171,5 +171,5 @@ def test_context_cov():
convr.__repr__()
convr.readlines()
convr.__str__()
convr.printall()
convr.print_all()
_ = convr == convr