From a92fc6a3efaddb13546410af9451208818d82db5 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 27 Apr 2026 08:39:09 +0200 Subject: ✨ import: more explicit error message on configuration error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_imports.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 26516cb7f..d26a20791 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -1404,21 +1404,21 @@ class FormaterType(models.Model): if self.options in dir(): model = dir()[self.options] else: + error_msg = str( + _("Configuration error - {} - invalid model for TypeFormater: {}.") + ).format(target, self.options) try: model = import_class(self.options) except (AttributeError, SuspiciousOperation): - logger.warning( - "**WARN FormaterType.get_formater_type**: {} " - "is not in valid.".format(self.options) - ) + raise ImporterError(error_msg) return + if not model: + raise ImporterError(error_msg) + return # must be explicit if non general type if self.options not in TARGET_MODELS_KEYS and \ not [True for m in model.__mro__ if m.__name__ == "GeneralType"]: - logger.warning( - "**WARN FormaterType.get_formater_type**: {} " - "is not in valid.".format(self.options) - ) + raise ImporterError(error_msg) return return TypeFormater(model, **kwargs) elif self.formater_type == "UnicodeFormater": -- cgit v1.2.3