Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unicode error catching #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion zulint/custom_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ def custom_check_file(
failed = False

with open(fn, encoding="utf8") as f:
contents = f.read()
try:
contents = f.read()
except UnicodeDecodeError as e:
print(f"unable to process file {fn} due to unicode decode error")
print(e)
return True
line_starts = [m.start() for m in re.finditer(r"^.", contents, re.M | re.S)]

rules_to_apply = self.get_rules_applying_to_fn(fn=fn, rules=self.rules)
Expand Down