Present a more user-friendly error if .gitgignore #2359
Labels
C: configuration
CLI and configuration
good first issue
Good for newcomers
S: accepted
The changes in this design / enhancement issue have been accepted and can be implemented
T: enhancement
New feature or request
Is your feature request related to a problem? Please describe.
Yes. When
.gitignore
is invalid, Black crashes with a confusingIndexError
exception and it's not obvious that the.gitignore
file is the issue. This is worsen by the fact, it's non-obvious Black uses.gitignore
at all (maintainer note: it's been documented so it's fine, just describing how this is even worse of a problem than at first glance).This is also a problem if say reading fails for some reason.
Describe the solution you'd like
If an exception is raised within the
get_gitignore
function, capture it and present a more user-friendly error without an unnecessary traceback and with a quick mention of.gitignore
.Describe alternatives you've considered
.gitignore
can't be parsed, just emit a warning and go on (fine, but I'm hesitant).gitignore
automatically (probably too much disruption potential)Additional context
I thought of this when triaging #2351.
The text was updated successfully, but these errors were encountered: