Skip to content

Commit

Permalink
fixes #37 and #38 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
fqrious authored Jan 3, 2025
1 parent 43f8279 commit cac5da1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dogesec_commons/stixifier/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions dogesec_commons/stixifier/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
raise ValidationError(f'invalid model: {value}') from e

0 comments on commit cac5da1

Please sign in to comment.