diff --git a/dogesec_commons/stixifier/serializers.py b/dogesec_commons/stixifier/serializers.py index 3a8343a..f799215 100644 --- a/dogesec_commons/stixifier/serializers.py +++ b/dogesec_commons/stixifier/serializers.py @@ -26,7 +26,7 @@ def validate_model(model): try: extractor = txt2stix.txt2stix.parse_model(model) except BaseException as e: - raise ValidationError(str(e)) + raise ValidationError(f"invalid model: {model}") return model def validate_extractor(typestr, types, name): diff --git a/dogesec_commons/stixifier/summarizer.py b/dogesec_commons/stixifier/summarizer.py index a4441ba..a1058c8 100644 --- a/dogesec_commons/stixifier/summarizer.py +++ b/dogesec_commons/stixifier/summarizer.py @@ -51,10 +51,12 @@ def parse_summarizer_model(value: str): splits = value.split(':', 1) provider = splits[0] if provider not in ALL_AI_EXTRACTORS: - raise Exception(f"invalid summary provider in `{value}`, must be one of [{list(ALL_AI_EXTRACTORS)}]") + raise ValidationError(f"invalid summary provider in `{value}`, must be one of [{list(ALL_AI_EXTRACTORS)}]") provider = get_provider(ALL_AI_EXTRACTORS[provider]) if len(splits) == 2: return provider(model=splits[1]) return provider() + except ValidationError: + raise except BaseException as e: - raise ValidationError(str(e)) from e \ No newline at end of file + raise ValidationError(f'invalid model: {value}') from e \ No newline at end of file