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

Feature Request: surface errors instead of warnings/swallowing #372

Closed
posita opened this issue Jan 14, 2022 · 2 comments
Closed

Feature Request: surface errors instead of warnings/swallowing #372

posita opened this issue Jan 14, 2022 · 2 comments

Comments

@posita
Copy link

posita commented Jan 14, 2022

In some cases, one might want to reject entirely an environment file that is un-parsable (e.g., to avoid unintended side-effects from a partial configuration or dotenvs internal attempts to make sense of things).

Is it possible to surface errors to a caller (e.g., a creator of DotEnv) somehow? I'm thinking of something like:

try:
  DotEnv(path_to_env, …, raise_on_parse_error=True)
except DotEnvParseError:
  logging.error(f"Couldn't parse {path_to_env}!")
except FileNotFoundError:
  logging.error(f"Couldn't find {path_to_env}!")
except PermissionError:
  logging.error(f"Couldn't read {path_to_env}!")
@cosama
Copy link

cosama commented May 6, 2022

I just run into a similar issue. If using this as a library then having error raised is essential in some cases. Personally, this could also be addressed by changing logging.warning calls to warning.warn calls, those could be caught (with a little bit of additional efforts) as well. Happy to work on this (raising Errors or warnings) if the developers here agree that this would be a welcome change.

@theskumar
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants