refactor: centralize failover error parsing

This commit is contained in:
Peter Steinberger
2026-01-10 01:25:01 +01:00
parent 82ffcfb181
commit 53ec8e36cb
7 changed files with 98 additions and 58 deletions

View File

@@ -249,6 +249,7 @@ describe("isFailoverErrorMessage", () => {
"429 rate limit exceeded",
"Your credit balance is too low",
"request timed out",
"invalid request format",
];
for (const sample of samples) {
expect(isFailoverErrorMessage(sample)).toBe(true);
@@ -263,9 +264,12 @@ describe("classifyFailoverReason", () => {
expect(classifyFailoverReason("resource has been exhausted")).toBe(
"rate_limit",
);
expect(classifyFailoverReason("invalid request format")).toBe("format");
expect(classifyFailoverReason("credit balance too low")).toBe("billing");
expect(classifyFailoverReason("deadline exceeded")).toBe("timeout");
expect(classifyFailoverReason("string should match pattern")).toBeNull();
expect(classifyFailoverReason("string should match pattern")).toBe(
"format",
);
expect(classifyFailoverReason("bad request")).toBeNull();
});
});