Catch exception (#5008)

* Catch exception

* Update settings.py

Don't print out exception message, just log error

* Update settings.py

Style fixes

* Update settings.py

Remove error message

* Update settings.py

Remove logger
This commit is contained in:
Oliver 2023-06-12 21:03:08 +10:00 committed by GitHub
parent 2f98ed7022
commit 8ca02cb105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,14 +7,13 @@ from moneyed import CURRENCIES
def currency_code_default():
"""Returns the default currency code (or USD if not specified)"""
from django.db.utils import ProgrammingError
from common.models import InvenTreeSetting
try:
code = InvenTreeSetting.get_setting('INVENTREE_DEFAULT_CURRENCY', create=False, cache=False)
except ProgrammingError: # pragma: no cover
# database is not initialized yet
except Exception: # pragma: no cover
# Database may not yet be ready, no need to throw an error here
code = ''
if code not in CURRENCIES:
@ -42,4 +41,4 @@ def stock_expiry_enabled():
"""Returns True if the stock expiry feature is enabled."""
from common.models import InvenTreeSetting
return InvenTreeSetting.get_setting('STOCK_ENABLE_EXPIRY')
return InvenTreeSetting.get_setting('STOCK_ENABLE_EXPIRY', False, create=False)