Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions leverage/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,17 @@ def parse_tf_file(file: Path):
Open and parse an HCL file.
In case of a parsing error, raise a user-friendly error.
"""
with open(file) as f:
try:
parsed = hcl2.load(f)
except lark.exceptions.UnexpectedInput:
raise ExitError(1, f"There is a parsing error with the {f.name} file. Please review it.")
else:
return parsed
try:
content = file.read_text()
parsed = hcl2.loads(content)
except lark.exceptions.UnexpectedInput as error:
raise ExitError(
1,
f"Possible invalid expression in file {file.name} near line {error.line}, column {error.column}\n"
f"{error.get_context(content)}",
)
else:
return parsed


class ContainerSession:
Expand Down
Loading
Loading