Skip to content

Commit 4af0a11

Browse files
fix(ofrep): handle invalid errorCode with try/except, fallback to GENERAL
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
1 parent fd48f58 commit 4af0a11

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • providers/openfeature-provider-ofrep/src/openfeature/contrib/provider/ofrep

providers/openfeature-provider-ofrep/src/openfeature/contrib/provider/ofrep/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ def _handle_error(self, exception: requests.RequestException) -> NoReturn:
185185
except JSONDecodeError:
186186
raise ParseError(str(exception)) from exception
187187

188-
error_code = ErrorCode(data.get("errorCode", "GENERAL"))
188+
try:
189+
error_code = ErrorCode(data["errorCode"])
190+
except ValueError:
191+
error_code = ErrorCode.GENERAL
189192
error_details = data["errorDetails"]
190193

191194
if error_code == ErrorCode.PARSE_ERROR:

0 commit comments

Comments
 (0)