cfpb / django-flags

Feature flags for Django projects
https://cfpb.github.io/django-flags/
Creative Commons Zero v1.0 Universal
260 stars 32 forks source link

Optionally catch exceptions in flag sources #20

Closed willbarton closed 5 years ago

willbarton commented 5 years ago

This change adds an option to get_flags to ignore any errors that occur when getting flags from a flag source. The ignore_errors option is False by default.

This allows the DatabaseFlagsSource to raise an OperationalError or ProgrammingError when running the system check before migrations have been applied without causing any issues.

ignore_errors is now used in the flag conditions system check so the check won't error when migrations have not yet been run.

Fixes #18 and closes #17.

willbarton commented 5 years ago

@chosak Yeah, I thought about catching a DatabaseError instead, but it's possible someone could create a flag source that reads from a particular file on disk and throws an OSError instead, or something like that.

I guess if you're going to ignore_errors, you have to really mean it. We'll see if this causes any issues. We can always add more complexity later 😁