diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-04-27 08:39:09 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-04-27 10:02:58 +0200 |
| commit | a92fc6a3efaddb13546410af9451208818d82db5 (patch) | |
| tree | 45751b523653147ebfe9d5bc7eec1c11a6dac8af | |
| parent | 29fa68e3157804bf2d6aeb157c305f021d0a8c45 (diff) | |
| download | Ishtar-a92fc6a3efaddb13546410af9451208818d82db5.tar.bz2 Ishtar-a92fc6a3efaddb13546410af9451208818d82db5.zip | |
✨ import: more explicit error message on configuration error
| -rw-r--r-- | ishtar_common/models_imports.py | 16 |
1 files 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": |
