Skip to content

Commit

Permalink
Log specific message when ParserSyntaxError happens (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Sep 18, 2023
1 parent 4aa3278 commit 849f34b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bump_pydantic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ def run_codemods(
fp.write(output_code)
fp.truncate()
return None, None
except cst.ParserSyntaxError:
return (
f"A syntax error happened on {filename}. This file cannot be formatted.\n"
"Check https://github.com/pydantic/bump-pydantic/issues/124 for more information.\n"
f"{traceback.format_exc()}"
), None
except Exception:
return f"An error happened on {filename}.\n{traceback.format_exc()}", None

Expand Down

0 comments on commit 849f34b

Please sign in to comment.