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

Catch FileNotFoundError in config.py - issue #384 #385

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
15 changes: 7 additions & 8 deletions invoke/config.py
Expand Up @@ -493,14 +493,13 @@ def _load_file(self, prefix, absolute=False):
setattr(self, path, filepath)
setattr(self, found, True)
break
# Typically means 'no such file', so just note & skip past.
except IOError as e:
# TODO: is there a better / x-platform way to detect this?
if "No such file" in e.strerror:
err = "Didn't see any {0}, skipping."
debug(err.format(filepath))
else:
raise
except (OSError, IOError) as e:
# Typically means `FileNotFound`, so just note & skip past.
# @see https://www.python.org/dev/peps/pep-3151/
debug("Didn't see any {0}, skipping: {1}".format(filepath, e))
except Exception:
raise

# Still None -> no suffixed paths were found, record this fact
if getattr(self, path) is None:
setattr(self, found, False)
Expand Down