Skip to content

Commit e23022c

Browse files
author
Tjaz Erzen
committed
Simplify codeplain_REST_api.py by providing a list of error codes that we should retry on
1 parent 776f3cc commit e23022c

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

codeplain_REST_api.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99
MAX_RETRIES = 4
1010
RETRY_DELAY = 3
1111

12-
NO_RETRY_ERROR_CODES = [
13-
"FunctionalRequirementTooComplex",
14-
"ConflictingRequirements",
15-
"CreditBalanceTooLow",
16-
"MissingResource",
17-
"PlainSyntaxError",
18-
"InternalServerError",
12+
# TODO: Handle connection errors
13+
RETRY_ERROR_CODES = [
14+
"LLMInternalError",
1915
]
2016

2117

@@ -81,8 +77,9 @@ def post_request(self, endpoint_url, headers, payload, run_state: Optional[RunSt
8177
return response_json
8278

8379
except Exception as e:
84-
if response_json is not None and response_json["error_code"] in NO_RETRY_ERROR_CODES:
85-
raise e
80+
if response_json is not None and "error_code" in response_json:
81+
if response_json["error_code"] not in RETRY_ERROR_CODES:
82+
raise e
8683

8784
if attempt < MAX_RETRIES:
8885
self.console.info(f"Error on attempt {attempt + 1}/{MAX_RETRIES + 1}: {e}")

0 commit comments

Comments
 (0)