Skip to content

Commit eed5ebb

Browse files
committed
Handle 'DedentError' gracefully
1 parent d5ecae6 commit eed5ebb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

gdtoolkit/formatter/__main__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ def _format_code(
312312
sep="\n",
313313
file=sys.stderr,
314314
)
315+
except lark.indenter.DedentError as exception:
316+
print(
317+
f"{file_path}:\n",
318+
str(exception),
319+
sep="\n",
320+
file=sys.stderr,
321+
)
322+
return 1
315323
except TreeInvariantViolation:
316324
success = False
317325
print(

gdtoolkit/linter/__main__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ def _lint_file(file_path: str, config: MappingProxyType) -> int:
158158
file=sys.stderr,
159159
)
160160
return 1
161+
except lark.indenter.DedentError as exception:
162+
print(
163+
f"{file_path}:\n",
164+
str(exception),
165+
sep="\n",
166+
file=sys.stderr,
167+
)
168+
return 1
161169

162170

163171
if __name__ == "__main__":

0 commit comments

Comments
 (0)