From 174c5faba570f23da096c426ee1042dc2335dcf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Fri, 3 Nov 2023 08:39:10 +0100 Subject: [PATCH] Add: Improve error handling for converting a CPE to the URI format Raise a descriptive error message during converting a CPE to the URI format (CPE v2.2) if transforming a part of the CPE fails. --- pontos/cpe/_cpe.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pontos/cpe/_cpe.py b/pontos/cpe/_cpe.py index 714b90ce..f51828f3 100644 --- a/pontos/cpe/_cpe.py +++ b/pontos/cpe/_cpe.py @@ -253,7 +253,10 @@ def bind_value_for_uri(value: Optional[str]) -> str: return "" if value == NA: return value - return _transform_for_uri(value) + try: + return _transform_for_uri(value) + except Exception as e: + raise CPEParsingError(f"Can't bind '{value}' for URI") from e def unbind_value_uri(value: Optional[str]) -> Optional[str]: