Skip to content

Commit

Permalink
fix(validation): fix error generation in expression validator
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Huber <maximilian.huber@tngtech.com>
  • Loading branch information
maxhbr committed Sep 27, 2023
1 parent e08e4d2 commit c08a9fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def parse_license_expression(license_expression_str: str) -> Union[LicenseExpres
try:
license_expression = Licensing().parse(license_expression_str)
except ExpressionError as err:
raise SPDXParsingError([f"Error parsing LicenseExpression: {err.args[0]}: {license_expression_str}"])
err_msg = "Error parsing LicenseExpression: "
err_msg += err.args[0] if f"{err.args[0]}: " else ""
err_msg += f"\"{license_expression_str}\""
raise SPDXParsingError([err_msg])

return license_expression
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_parse_license_expression(license_expression_str, expected_license):
"invalid_license_expression,expected_message",
[
(56, ["Error parsing LicenseExpression: expression must be a string and not: <class 'int'>: 56"]),
("LGPL-2.1, GPL-2.0, GPL-3.0",["Error parsing LicenseExpression: \"LGPL-2.1, GPL-2.0, GPL-3.0\""]),
],
)
def test_parse_invalid_license_expression(invalid_license_expression, expected_message):
Expand Down

0 comments on commit c08a9fb

Please sign in to comment.