Skip to content

Commit ddf0ec2

Browse files
fix RenderingCreditBalanceTooLow error code handling
The client mapped the API error code "CreditBalanceTooLow" but the server actually sends "RenderingCreditBalanceTooLow", so the error fell through to a generic "400 Client Error: BAD REQUEST" message instead of surfacing the server's message (which contains the purchase/upgrade URL). Align the client with the server's error code and pass the server message through unchanged.
1 parent 70150ef commit ddf0ec2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

codeplain_REST_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
ERROR_CODE_EXCEPTIONS = {
1919
"FunctionalRequirementTooComplex": plain2code_exceptions.FunctionalRequirementTooComplex,
2020
"ConflictingRequirements": plain2code_exceptions.ConflictingRequirements,
21-
"CreditBalanceTooLow": plain2code_exceptions.RenderingCreditBalanceTooLow,
21+
"RenderingCreditBalanceTooLow": plain2code_exceptions.RenderingCreditBalanceTooLow,
2222
"LLMInternalError": plain2code_exceptions.LLMInternalError,
2323
"MissingResource": plain2code_exceptions.MissingResource,
2424
"PlainSyntaxError": plain2code_exceptions.PlainSyntaxError,
@@ -99,8 +99,8 @@ def _raise_for_error_code(self, response_json):
9999
raise plain2code_exceptions.MissingResource(f"Missing resource: {message}\n")
100100
if error_code == "ConflictingRequirements":
101101
raise plain2code_exceptions.ConflictingRequirements(f"Conflicting requirements: {message}\n")
102-
if error_code == "CreditBalanceTooLow":
103-
raise plain2code_exceptions.RenderingCreditBalanceTooLow(f"Credit balance too low: {message}\n")
102+
if error_code == "RenderingCreditBalanceTooLow":
103+
raise plain2code_exceptions.RenderingCreditBalanceTooLow(message)
104104
if error_code == "LLMInternalError":
105105
raise plain2code_exceptions.LLMInternalError(f"LLM internal error: {message}\n")
106106
if error_code == "PlainSyntaxError":

0 commit comments

Comments
 (0)